ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA Type »yªk¿ù»~°T®§

[µo°Ý] VBA Type »yªk¿ù»~°T®§

OS¡GWIN 7¡AEXCEL 2010

¦b Type «e­±¥[¤W Private©ÎPublic ¤]¬O¤@¼Ë¿ù»~

¦b¼Ò²Õ©Î¬¡­¶Ã¯«Ø¥ßµ{¦¡½X¡A¤]¬O¿ù»~

§Ú°O±o¥H«e¨Ï¥Î2003ª©¥»¦n¹³¨S°ÝÃD¡A¥u¬O²{¦b¨S³o­Óª©¥»¥i¥H´ú¸Õ

½Ð°Ý¬O¥X¤F¤°»ò°ÝÃD¡H

Sub test2()

Type MyType
    MyName As String    ' String variable stores a name.
    MyBirthDate As Date    ' Date variable stores a birthdate.
    MySex As Integer    ' Integer variable stores sex (0 for
End Type    ' female, 1 for male).

End Sub

¦^´_ 1# lcc_seven
VBA ªº»¡©ú ¤Î½d¨Ò
Type ³¯­z¦¡½d¨Ò   
¥»½d¨Ò¨Ï¥Î Type ³¯­z¦¡¨Ó©w¸q¨Ï¥ÎªÌ¦Û­qªº¸ê®Æ«¬ºA¡CType ³¯­z¦¡¥u¯à¦b¼Ò²Õ¼h¯Å¤¤¨Ï¥Î¡C¦pªG­n¦bª«¥óÃþ§O¼Ò²Õ¤¤¨Ï¥Î¡AType ³¯­z¦¡ªº«e­±¤@©w­n¥[¤W Private ÃöÁä¦r¡C
  1. Type EmployeeRecord    ' «Ø¥ß¨Ï¥ÎªÌ¦Û­qªº¸ê®Æ«¬ºA¡C
  2.     ID As Integer    ' ©w¸q¸ê®Æ«¬ºAªº¤¸¯À¡C
  3.     Name As String * 20
  4.     Address As String * 30
  5.     Phone As Long
  6.     HireDate As Date
  7. End Type
  8. Sub CreateRecord()
  9.     Dim MyRecord As EmployeeRecord    ' «Å§iÅܼơC
  10.     ' ¹ïÅÜ¼Æ EmployeeRecord ªºµ¹­È°Ê§@¥²»Ý¦bµ{¬Y­Ó§Ç¤¤¤~¥i¥H¡C
  11.     MyRecord.ID = 12003    ' µ¹©w¬Y­Ó¤¸¯Àªº­È¡C
  12. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ lcc_seven ©ó 2012-7-21 17:57 ½s¿è

¦^´_ 2# GBKEE
½d¨Ò½XµL¿ù»~°T®§¡A¥i¥H°õ¦æ¡A·PÁ¦^´_~~

¥u¬O»¡¤]©_©Ç¡A§Ú­è­è¤]¦³§â Type ©ñ¦b Sub ¤º¸ò Sub ¥æ¤e´ú¸Õ¹L¡A³£¦³¿ù»~°T®§

«ç»ò²{¦b´N¥i¥H¤F¡H

====================================================

­è­è¦b´ú¸Õ¤F¤@¤U¡Aµo²{¬O¦Û¤v·d¯QÀs¡A§â Type ©ñ¦b Sub ¤U­±¡A¦Ó¤£¬O¦b¼Ò²Õ³Ì¤W¤è¡AÃø©Ç·|µo¥Í¿ù»~¡C

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD