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

[µo°Ý] ¦p¦ó¥Î°j°éªºi©I¥sÅܼÆ

[µo°Ý] ¦p¦ó¥Î°j°éªºi©I¥sÅܼÆ

§Ú¦³¤@­Óµ{¦¡½X,·|»Ý­n­«½Æ¨Ï¥Î
¦ý¸Ì­±ªº¤å¦r±Ô­z»Ý­n§ó§ï
¦]¦¹§Ú¥ý±N¤å¦r©w¸q¬°
s1_1="§Ú·R§A"
s1_2="§Ú¤£·R§A"
s2_1="§Ú·Q§A"
s2_2="§Ú¤£·Q§A"

§Úªº¥Øªº¬O§Æ±æ²²¤¨Ï¥Îµ{¦¡½X
§Ú¥i¥Hif i = 1 then s1 =s1_1.....¦ý­Y¬O§Úªºi´N¦³¤@¤d­Ó§Ú·|¥´¦º
¦]¦¹¬O§_¥i¥H¦p¤U¨Ï¥Î
§âÅܼƻPi¦X¨Ö¨Ï¥Î,´N§Ö¦h¤F
  1.     For i = 1 To 2
  2.         s1 = "s1_" & i
  3.         s2 = "s2_" & i
  4.         Call check¦C¥XÀÉ®×
  5.     Next
½Æ»s¥N½X
·íµM¥Ø«e¤W­zµ{¦¡½X¬O¤£¯à¨Ï¥Îªº¦]¬°s1·|="s1_1"¦Ó¤£¬Oµ¥©ó"§Ú·R§A"

§Ú¥uª¾¹Duserform¥i¥H³o¼Ë¨Ï¥Î¨Ò¦pset ctrl=controls("s" & i)
¦ý¤£¬Ouserformªº±±¨î¶µ,¦Ó¬OÅܼƭn¦p¦ó¹F¨ì§Ú¤W­zµ{¦¡½X¯uªº­n¹F¦¨ªºµ²ªG©O?
PKKO

¥H¤U¥u¬O¥Ü¨Ò¡G
Dim SR(1 to 2, 1 to 99)
SR(1,1)="§Ú·R§A"
SR(1,2)="§Ú¤£·R§A"
SR(2,1)="§Ú·Q§A"
SR(2,2)="§Ú¤£·Q§A"
For i = 1 To 2
     s1 = SR(1,i)
     s2 = SR(2,i)
     Call check¦C¥XÀÉ®×
Next

¤@¤d­Ó²Ó¶µ¡A¥i¨Ï¥Î¤u§@ªí¦C¥X©ú²Ó¹ï·Ó¡C

TOP

½Ð±ÐDim SR(1 to 2, 1 to 99)¬O¦h­«°}¦C¥Îªk¡H

TOP

¦^´_ 2# ­ã´£³¡ªL


    ·PÁ¦^´_,¥­±`¥u¦³·Q¨ì¥Î°}¦C±a¤J¸ê®Æ,¨S¦³·Q¹L§âÅܼƪº­È±a¤J°}¦C,¦A¥Ñ°j°é§â°}¦C¤º®e±a¥X¨Ó
ÁöµM¦h¤@¹D¤u,¤£¹L¤´µM¥i§¹¦¨»Ý¨D! ·P®¦!
PKKO

TOP

¤]¥i¥H¥Î Collection, ¤£¥Î«Å§i«Ü¤jªº Array, ¤]¤£¥Î°ÊºA«Å§iArray

TOP

¥»©«³Ì«á¥Ñ PKKO ©ó 2015-1-20 22:33 ½s¿è

¦^´_ 5# diolin
·PÁÂ,¤S¦¬Ã¬¤F!
PO¤W½d¨Ò»¡©ú

Collection ª«¥ó½d¨Ò
¥»½d¨Ò«Ø¥ß¤@­Ó©R¦W¬° MyClasses ªº Collection¡A¨Ã¥B¦A«Ø¥ß¤@­Ó¹ï¸Ü¤è¶ô¡AÅý¨Ï¥ÎªÌ¥i±q¹ï¸Ü¤è¶ô¤¤±Nª«¥ó·s¼W¨ì¸Ó¶°¦Xª«¥ó¤¤¡C­Y­nÆ[¹îµ{¦¡¦p¦ó¹B§@¡A½Ð¥ý¦b¡u´¡¤J¡v¥\¯àªí¤W¿ï¨ú¡uª«¥óÃþ§O¼Ò²Õ¡v«ü¥O¡AµM«á¦b Class1 ªº¼Ò²Õ¼h¦¸¤¤«Å§i¤@­Ó¤½¥ÎÅܼơA©R¦W¬° InstanceName (Public InstanceName)¡A¦¹ÅܼƥΨÓÀx¦s¨C­Óª«¥óÃþ§O°õ¦æ­ÓÅ骺¦WºÙ¡C¤£­n§ó§ïª«¥óÃþ§Oªº¹w³]¦WºÙ Class1¡C±N¤U¦Cµ{¦¡½X½Æ»s¨ì¥t¤@­Ó¼Ò²Õªº¡u¤@¯ë¡v°Ï¬q¤¤¡AµM«á¦b¥t¤@­Óµ{§Ç¤¤¥H ClassNamer ³¯­z¦¡¨Ó±Ò°Ê¤§¡C(¥»½d¨Ò¥u¾A¥Î©ó¦³¤ä´©ª«¥óÃþ§Oªº¥Dµ{¦¡¡C)
  1. Sub ClassNamer()
  2.     Dim MyClasses As New Collection    ' «Ø¥ß¤@­Ó¶°¦Xª«¥ó (Collection)¡C
  3.     Dim Num    ' °O¼Æ¥ÎÅܼơA¥Î¨Ó°O¼Æª«¥ó­Ó¼Æ¡C
  4.     Dim Msg As String    ' ´£¥Ü°T®§¥ÎÅܼơC
  5.     Dim TheName, MyObject, NameList    ' ª«¥ó¸ê°T¥ÎÅܼơC
  6.     Do
  7.         Dim Inst As New Class1    ' «Ø¥ß Class1 ªº·s°õ¦æ­ÓÅé¡C
  8.         Num = Num + 1    ' §â°O¼ÆÅÜ¼Æ Num ¥[¤@¡AµM«á­n¨D¨Ï¥ÎªÌ¿é¤J·sª«¥ó­ÓÅ骺¦WºÙ¡C
  9.         Msg = "Please enter a name for this object." & Chr(13) _
  10.          & "Press Cancel to see names in collection."
  11.         TheName = InputBox(Msg, "Name the Collection Items")
  12.         Inst.InstanceName = TheName    ' ±N¦WºÙ«ü©wµ¹·sª«¥ó­ÓÅé¡C
  13.         ' ±N¨Ï¥ÎªÌ¿é¤Jªº¦WºÙ¥[¨ì¶°¦Xª«¥ó¤¤¡C
  14.         If Inst.InstanceName <> "" Then
  15.             ' ±N·s¦WºÙ¥[¨ì¶°¦Xª«¥ó¤¤¡C
  16.             MyClasses.Add item := Inst, key := CStr(Num)
  17.         End If
  18.         ' ±N²{¦bª«¥óªº¤Þ¥ÎÄÀ©ñ±¼¡A¥H¹ï¤U¤@­Óª«¥ó°µ°Ê§@¡C
  19.         Set Inst = Nothing
  20.     Loop Until TheName = ""
  21.     For Each MyObject In MyClasses    ' «Ø¥ßª«¥ó¦WºÙ²M³æ¡C
  22.         NameList = NameList & MyObject.InstanceName & Chr(13)
  23.     Next MyObject
  24.     ' ±N¦WºÙ²M³æ¥H°T®§¤è¶ôÅã¥Ü¥X¨Ó¡C
  25.     MsgBox NameList, , "Instance Names In MyClasses Collection"

  26.     For Num = 1 To MyClasses.Count    ' ±N¦Uª«¥ó±q¶°¦Xª«¥ó¤¤²¾°£¡C
  27.         MyClasses.Remove 1    ' ¦]¬°¨C²¾°£¤@­Óª«¥ó«á¡A¶°¦Xª«¥ó
  28.                 ' ¥»¨­·|¦Û°Ê­«±Æª«¥ó¶¶§Ç¡A¬G°j°é¤¤¥u»Ý­n²¾°£²Ä¤@­Ó
  29.     Next        ' ª«¥ó§Y¥i¡C
  30. End Sub
½Æ»s¥N½X
PKKO

TOP

        ÀR«ä¦Û¦b : ­ì½Ì§O¤H´N¬Oµ½«Ý¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD