|
-
Sep 22nd, 2000, 08:04 AM
#1
Thread Starter
New Member
if i got a variable MyServer , MyStatus , MyQuitMsg ...
how do i use 'for each' to see if it's NULL ?
--
it's really hard to be a man in a world that's full of beauty.
-
Sep 22nd, 2000, 08:09 AM
#2
When you use the For Each statement, I don't there is a easy way to check variables of different names as the For Each statement will be looping back to the same name everytime, but it can easily be done with variable arrays.
Sunny
-
Sep 22nd, 2000, 08:21 AM
#3
Thread Starter
New Member
can you give me a sample?
ey... can u give me a sample? cause it's not just 3 variables... i'm trying to check lots of vars..
--
it's really hard to be a man in a world that's full of beauty.
-
Sep 22nd, 2000, 08:25 AM
#4
Code:
Private Sub Form_Load()
Dim var(99) As String
Dim i, count As Integer
For i = 0 To 99
If var(i) = "" Then
count = count + 1
End If
Next i
MsgBox count & " variables were empty"
End Sub
The code will go through all 100 variables (0 - 99) checking each one to see if it is empty.
Sunny
-
Sep 22nd, 2000, 08:38 AM
#5
Thread Starter
New Member
--
it's really hard to be a man in a world that's full of beauty.
-
Sep 22nd, 2000, 08:43 AM
#6
_______
<?>
Code:
'using a collection for storing variables
Public myVar As Collection
Private Sub Form_Load()
Set myVar = New Collection
myVar.Add ""
myVar.Add "Wayne"
myVar.Add "Jim"
myVar.Add ""
myVar.Add "Juillet"
myVar.Add "Rosie"
End Sub
Private Sub Command1_Click()
'are any of the variables empty
Dim i As Integer
For i = 1 To myVar.Count
If myVar(i) = "" Then
MsgBox "myVar " & i & "= nothing!"
End If
Next i
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 22nd, 2000, 08:48 AM
#7
Using a collection would a better choice for ease of use, unless you really wanted to use the For Each statement ("how do i use for each"?).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|