-
Is there anyway to use sets in VB like in TP
in TP you could do
readln (num);
if num in [0..9] = true then
writeln ('It is a single digit!')
else if num in [-99..-10,10..99] = true then
writeln ('It is double digit!);
is there anything lite that in VB or would I have to use
num >= -99 and num <= -10 or Num <= 99 and num >= 10
-
Hi there, I hope this helps you (and makes sense):
Code:
Select Case num
' if num in [0..9] = true then
Case 0 To 9
' writeln ('It is a single digit!')
Debug.Print "It's a single digit"
' else if num in [-99..-10,10..99] = true then
Case -99 To -10, 10 To 99
' writeln ('It is double digit!);
Debug.Print "It is double digit!"
End Select
I am not claiming to be proficient in Pascal, by the way, but the code should work the same way.
-
Haven't tried it but how about
if IsNumeric(num) and len(abs(num)) = 1 then writeln ('It is single digit!);
if IsNumeric(num) and len(abs(num)) = 2 then writeln ('It is double digit!);
[Edited by JHausmann on 08-17-2000 at 06:55 PM]
-
Yeah, I haven't tried that either, but I think the Captain's problem was more that he wanted to work with ranges of values than to find the number of digits.
You can use the Case ... To ..., ... To ... with numeric values, strings, and so forth. Check out the Select Case...End Select statement block in the Visual Basic documentation. It is a very efficient and flexible construct.