PDA

Click to See Complete Forum and Search --> : Why?


thinh
Dec 31st, 1999, 10:18 AM
Hi, look at the code below...Sub cmdGet()
N = 0
Dim ret As Long
Dim Temp As String * 100
Do Until ret <= 1
N = N + 1
ret = GetPrivateProfileString(AppName, "n" & N, vbNull, Temp, Len(Temp), FlName)
If ret <= 1 Then
GoTo nextn
Else
Sleeping.List1.AddItem Trim(Temp)
End If
nextn:
Loop
End Sub

then the sub doesn't work. and when i replace the Do with the For statement it works. can anybody show me what's wrong...

Dec 31st, 1999, 04:47 PM
RET is immediately less than 1, so it never executes!!!

when you Dim a new variable, it sets it to 0.

theres your problem.
if you want it to execute at least once, put the Until ret <=1 next to the loop word

thinh
Jan 2nd, 2000, 10:52 AM
thank you wossman