Results 1 to 4 of 4

Thread: for those of you who know Turbo Pascal.,..

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    London, ON
    Posts
    40

    Question

    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

  2. #2
    Fanatic Member HaxSoft's Avatar
    Join Date
    May 2000
    Location
    Ohio
    Posts
    593
    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.

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    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]

  4. #4
    Fanatic Member HaxSoft's Avatar
    Join Date
    May 2000
    Location
    Ohio
    Posts
    593
    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
  •  



Click Here to Expand Forum to Full Width