-
Sep 13th, 2001, 01:07 PM
#1
Thread Starter
New Member
control structure in VB ( and, continue, do...while )
how to convert these control structure java code to VB?
1. and (&&) in "if"
if( i < 10 && b[i] < 5 ) // note, if i >=10, java does not check b[i]<5
{
...
}
2. dose vb have "continue"?
for( int i=0; i<10; i++)
{
if( a<10)
continue;
...
}
3.
do
{
} while( i<10 && a[i] <5 );
thanks! -Zhining
-
Sep 13th, 2001, 01:16 PM
#2
Hyperactive Member
VB Code:
' 1.
If i < 10 And b(i) < 5 Then
' Do stuff
End If
' 2.
Do While (a < 10)
' Do stuff
Loop
' 3.
Do
' Do stuff
Loop While (i < 10 And a(i) < 5)
-
Sep 13th, 2001, 01:19 PM
#3
1.
if( i < 10 && b[i] < 5 ) // note, if i >=10, java does not check b[i]<5
{
...
}
Code:
if (i < 10) AND (b(i) < 5) then
'Do something
end if
2.
for( int i=0; i<10; i++)
{
if( a<10)
continue;
...
}
Code:
For i=0 to 9
'Continue isn't a part of vb, but the test could be written like this
if a >= 10 then exit for 'This will break the for loop
next i
3.do
{
} while( i<10 && a[i] <5 );
Code:
do
loop while (i < 10) AND (a(i) < 5)
That should do it
-
Sep 13th, 2001, 01:34 PM
#4
Thread Starter
New Member
thanks Rudgej and AIS_DK for you quick responses!!!
But I still have the problem "of and in if". Please look at the following code. I got an error.
In java and C, if i>=3, it won't check a( i) > 99, so no problem in java.
thanks!
===================
Dim a(3) As Integer
Dim i As Integer
i = 10
If i < 3 And a(i) > 99 Then ' script out of range, since i >= 3
MsgBox "hello"
End If
==================
-
Sep 13th, 2001, 01:39 PM
#5
Fanatic Member
VB Code:
Dim a(3) As Integer
Dim i As Integer
i = 10
If i < 3 Then
If a(i) > 99 Then
MsgBox "hello"
End If
End If
In VB it checks all conditions of the contditional before it decides what's true and what's not. Completely opposite from every other language on the planet This should work for you.
-
Sep 13th, 2001, 01:45 PM
#6
Thread Starter
New Member
thanks, Excalibur!
My VB code will be longer than java code, and it is much harder to maintain.
Thanks again for your helps!
-Zhining
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
|