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

[µo°Ý] Is Nothing»PEmptyªº¥Îªk

[µo°Ý] Is Nothing»PEmptyªº¥Îªk

­n½T»{¬Y¤@°}¦C¬O§_¦s¦b®É¸Ó¥Î¤°»ò¤èªk§PÂ_?
ReDim HeadSone(20)
t1 = 0
t2 = 0
j = 0
For fsi = 15 To 238
    If Cells(fsi, 5) = Cells(fsi + 1, 5) And Cells(fsi, 5) <> Cells(fsi - 1, 5) Then t1 = fsi
    If Cells(fsi, 5) = Cells(fsi - 1, 5) And Cells(fsi, 5) <> Cells(fsi + 1, 5) Then t2 = fsi
        If t1 <> 0 And t2 <> 0 Then
            Set HeadSone(j) = Range(Cells(t1, 5), Cells(t2, 5))
            HS_S(j) = t1
            HS_E(j) = t2
            j = j + 1
            t1 = 0
            t2 = 0
        End If
Next fsi
m = j - 1   '¦@¦³m-1²Õ
If HeadSone(0) = Empty Then  '§PÂ_HeadSone(0)¬O§_¦s¦b
    m = 0
Else
    m = j - 1   '¦@¦³m-1²Õ
End If
ReDim Preserve HeadSone(m)

·íHeadSone(0)¤£¦s¦b®É¤W­z¼gªkOK,¥i¬O·íHeadSone(0)¤£¦s¦b®É¤W­z¼gªk´N·|¥X²{¿ù»~(«¬ºA¤£²Å¦X)
§ï¦¨:
If HeadSone(0) = Is Nothing Then
    m = 0
Else
    m = j - 1   '¦@¦³m-1²Õ
End If

·íHeadSone(0)¤£¦s¦b®É«h·|¥X²{¿ù»~(¦¹¦¸»Ý­nª«¥ó),¥i¬O·íHeadSone(0)¤£¦s¦b®É¸Ó¼gªk´NOK
½Ð°ÝIs Nothing»PEmptyªº¥Îªk¦³¦ó¤£¦P?¸Ó¦p¦ó§ï?

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-9-26 16:48 ½s¿è

¦^´_ 1# acdx
§A¥i¥H§ï¬° ReDim HeadSone(0 to 20) As Range
´N¥i¥Hª½±µ¥Î  If HeadSone(0) Is Nothing §PÂ_

TOP

¦^´_ 1# acdx
³oºô¯¸¸ê°TÆZ­È±o§A°Ñ¦Ò¡G
w3schools.com

TOP

¦^´_ 1# acdx
  1. Set HeadSone(0) = Nothing
  2. If HeadSone(0) Is Nothing Then
½Æ»s¥N½X
  1. ReDim Preserve HeadSone(m)
  2. If TypeName(HeadSone(0)) = "Empty" Then
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE
¥t¥~
­Y¬O§Ú·Q±NHeadSone(m)¥þ¼Æ²MªÅ
Set HeadSone(0)=Nothing
Set HeadSone(1)=Nothing
Set HeadSone(2)=Nothing
....
¸Ó¦p¦ó¼g¤ñ¸û¦n?

TOP

¦^´_ 5# acdx
  1. Erase ³¯­z¦¡¨Ó±N©T©w¤j¤pªº°}¦C­«·sªì©l¤Æ¡A©Î±N°ÊºA°}¦Cªº°O¾ÐªÅ¶¡ÄÀ©ñ¥X¨Ó¡C
½Æ»s¥N½X
  1. Option Explicit
  2. Sub Ex()
  3.     Dim HeadSone(1 To 5)            'ÀRºA°}¦C:«ü©w°}¦C¤¸¯À,¤U­­=1,¤W­­=5
  4.     HeadSone(1) = 0
  5.     MsgBox TypeName(HeadSone(1))
  6.     HeadSone(1) = "AA"
  7.     MsgBox TypeName(HeadSone(1))
  8.     Erase HeadSone                  '²MªÅ°}¦Cªº¤¸¯À:ÀRºA°}¦C:«ü©w°}¦C¤¸¯À,¤U­­=1,¤W­­=5
  9.     MsgBox TypeName(HeadSone(1))
  10. End Sub
  11. Sub Ex1()
  12.     Dim HeadSone()                  '°ÊºA°}¦C:©|¥¼«ü©w°}¦C¤¸¯À¤U­­,¤W­­¼Æ
  13.     ReDim HeadSone(1 To 5)          '­«·s«ü©w°}¦C¤¸¯À¤U­­,¤W­­¼Æ
  14.     MsgBox TypeName(HeadSone(1))
  15.     HeadSone(1) = 0
  16.     'Erase HeadSone  '               '±N°ÊºA°}¦Cªº°O¾ÐªÅ¶¡ÄÀ©ñ¥X¨Ó,¦^¨ì°ÊºA°}¦C:©|¥¼«ü©w°}¦C¤¸¯À¤U­­,¤W­­¼Æ
  17.    ' MsgBox TypeName(HeadSone(1))    '¿ù»~:°}¦C¨S¦³¤¸¯À  *****
  18.     ReDim HeadSone(1 To 5)          '­«·s«ü©w°}¦C¤¸¯À¤U­­,¤W­­¼Æ = ²MªÅ°}¦Cªº¤¸¯À
  19.     MsgBox TypeName(HeadSone(1))
  20. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¨S¦³©Ò¦³Åv¡A¥u¦³¥Í©Rªº¨Ï¥ÎÅv¡C
ªð¦^¦Cªí ¤W¤@¥DÃD