|
-
Aug 17th, 2000, 03:21 PM
#1
Thread Starter
Member
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
Visual Basic 6 Professional Edition
Captain Pinko
also:
Turbo Pascal, Turing, QBasic
-
Aug 17th, 2000, 03:55 PM
#2
Fanatic Member
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.
-
Aug 17th, 2000, 05:45 PM
#3
Frenzied Member
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]
-
Aug 17th, 2000, 06:10 PM
#4
Fanatic Member
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.
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
|