Can I judge whether the dynamic array is all assigned?

zhaozj2021-02-16  60

The dynamic array can often play a hiking role in the VB language. However, there is no redefined or released, "IS EMPTY", "is null", "=" "", etc. Therefore, it is generally used to detect the method of detecting an error message (on error). The following is given a non-error-detected code, and it is determined that the allocation of the dynamic string array:

PRIVATE SUB Command1_Click () Dim A () AS String, i as long

Msgbox Hasredim (a), 64, "HAS A () been redimed?" Is not initialized

Redim a (20)

FOR i = 1 to 20a (i) = chr (i 64)

NEXT

Msgbox Hasredim (a), 64, "HAS A () been redimed?" Is initialized

ERASE A 'Releases Space Msgbox Hasredim (a), 64, "HAS A () Been RedIMed?"

End Sub

Function hasredim (byref x () as string) as boolean 'defines the Boolean function DIM TEMP AS STRINGTEMP = JOIN (X, ") Hasredim = lenb (temp)> 0' empty array length is zero end function

转载请注明原文地址:https://www.9cbs.com/read-23734.html

New Post(0)