Results 1 to 4 of 4

Thread: Number Lists can u help? :0)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    WALES UK
    Posts
    31
    Is it possible to enter 2 numbers, say 100 and 300 and get vb to produce a list of the numbers and store them in a database
    so if the user typed 100 as the lowest and 300 as the highest the program would put 100,101,102,103....300 into my database?

    thanx in advance....
    Rhys


  2. #2
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    Need to add validation yourself...
    Code:
    Dim lFrom as long, lTo as Long, l as Long
    ' check if values are entered
    ' code goes here
    
    ' read out entered values
    lFrom = Clng(Val(Text1.Text))
    lTo = Clng(Val(Text2.Text))
    ' validate if From < To
    ' code goes here
    
    ' loop from lFrom to lTo
    For l = lFrom to lTo
        ' do something with l
        ' code for adding to database goes here
    Next
    Hope this helps

    Crazy D

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    WALES UK
    Posts
    31
    Thanx but is there an easier way? anybody?

    cheers though

    Rhys

  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Crazy D's way is easiest.
    here:
    For n = 100 to 300
    text1.text = text1.text & " " & n
    next n
    add the above code to a project then add a textbox and run. What will result will text1.text will have all the numbers from 100 to 300

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