VideoHelp Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. I need to search a string opened from a text file to see if an inputted number matches a value with the file.

    so;

    Code:
    inputnum as integer, numfound as boolean
    
    inputnum = val(txtinput.text)
    
    open alreadyusednums.txt for input as #9
            do until numfound = true
                  
    'what do i do here
    'once found, numfound = true               
                  
            loop
    close #9

    alreadyusednums.txt would look like this

    Code:
    154
    3545
    25
    645
    234
    7777
    223
    7677
    2
    3443
    334
    4535
    Quote Quote  
  2. Member SaSi's Avatar
    Join Date
    Jan 2003
    Location
    Hellas
    Search Comp PM
    Assuming you are reading the file to find numbers matching "inputnum", then the reading code should be like:

    Dim s as string
    Open alreadyusednums.txt for input as #9

    Do Until numfound = True

    Line Input #9, s
    if isnumeric(s) Then
    if val(s) = inputnum then numfound = true
    endif
    loop

    The If Isnumeric(s) line is there in case your .txt file contains an empty line, which would cause val(s) to generate a type mismatch error.
    The more I learn, the more I come to realize how little it is I know.
    Quote Quote  
  3. I actually found a way to do it after I posted, came back here in about 30min and you had found a better way!

    that was fast
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!