Thread: visual basic

  1. #1
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125

    visual basic

    Hi all;

    I know this is not a Visual basic board but i figured there has to be someone here who can help me out. My problem is when i read through a text file i need to extract only the numeric data from the file. The real problem is that this needs to be done in visual basic, and i do not know where to start. I have opened up the file and read in its contents line by line

    Do Until EOF(1)
    Input #1, strIn
    Loop

    but i do not know how to validate the strIn string for numeric data.

    Thanks for you time.
    arrh, i got nothing good to say.
    http://www.praxis1.vic.edu.au/home/dcola/

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Noones gonna help you here b/c this site isnt for basic or visual basic so go somewhere else! Try the general programming forum at www.gamedev.net i know there are a lot of VB programmers there.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    363
    I'm with xds4lx on this one. Visual Basic is evil and must be eradicated from the face of the earth.

    And as to your actual problem, try reading it to a string variable then use the Val function. It'll atleast be a number that way.
    If you own a piece of land and there is an volcano on it and it ruins a
    nearby town, do you have to pay for the property damage?

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Try asking on the forums at www.programmersheaven.com
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    Re: visual basic

    Try this ( I'm probably going to get shot for answering this... sorry guys/gals ):

    Anyone offended by the site of VB code should cover their eyes before reading further....

    Code:
    dim iFF as integer, iStrLen as integer, iMidCntr as integer
    dim iLineLen as integer
    dim sFileName as string, sLineIn as string, sMid as string
    dim bNumFnd as boolean
    
    bNumFnd = false
    iFF = Freefile
    sFileName="C:\test.txt"
    open sFileName for input as #iFF
     do while not eof(iFF)
       line input #iFF, sLineIn
       iLineLen=len(sLineIn)
       for iMidCntr = 1 to iLineLen
         if IsNumeric(mid$(sLineIn,iMidCntr,1)) then
           bNumFnd = true //this would be where you do your extraction
         end if
         if bNumFnd then bNumFnd=false //reset it before reading in the next bit of data
       next iMidCntr
     loop
    close #iFF
    Since I'll probably be banned for answering this... for future VB questions go to the VB Explorer Forums at http://pub13.ezboard.com/bvisualbasicexplorer or their main page at www.vbexplorer.com .

    Oh, man, I just realized I used hungarian notation in my example..

    **hides before DavidP catches him in this blasphemous act**

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> I'm probably going to get shot for answering this

    Help when you can man. I also use VB from time to time, the only reason I didn't try to help other than post a link was that I was busy, and I don't have VB in the office, (one has certain standards you know!).
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I'm probably going to get shot for answering this
    Why? VB isn't the best language, but that doesn't mean it should never be used. As adrianxw said, help out whenever you can.

    >Oh, man, I just realized I used hungarian notation in my example..
    This might get you shot, hungarian notation is the devil's spawn.

    -Prelude
    My best code is written with the delete key.

  8. #8
    Registered User
    Join Date
    Jan 2002
    Posts
    363
    >>This might get you shot, hungarian notation is the devil's spawn.

    *Discalimer*
    The views contained in the following post do not in any way reflect upon the belifes of any real person. The post is purely for educational purposes and does not in any way support or endorse the use of hungarian notation in any form.
    *Disclaimer*


    Why is hungrain notation bad again?
    If you own a piece of land and there is an volcano on it and it ruins a
    nearby town, do you have to pay for the property damage?

  9. #9
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    I was just joking. I mentioned DavidP because I know he has a comment about hungarian notation in his signature.

    Why? VB isn't the best language, but that doesn't mean it should never be used
    I was half-joking here. I make my living in VB (well most of it, probably about 70 (VB) - 30 (C++) ).

    A lot of VB programmers have the idea that they are considered "lesser" developer (happens to be a popular topic on VB forums) by C/C++ programmers. I don't believe it. I think VB has it's strengths (especially for rapid DB development) and I made it clear when I first started posting here that I was coming from a VB background and everyone was really helpful and friendly.

  10. #10
    Seņor Member
    Join Date
    Jan 2002
    Posts
    560
    I think that's because VB is so easy to use, C/C++ programmers like to torture themselves, it makes them feel better about themselves i guess.

  11. #11
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125
    Thank you so much jdinger. Your help was very usful to me. thank you again.

    danno
    arrh, i got nothing good to say.
    http://www.praxis1.vic.edu.au/home/dcola/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 11-23-2007, 12:13 AM
  2. Run Visual Basic code inside C++?
    By torbjoen in forum Windows Programming
    Replies: 8
    Last Post: 07-31-2002, 11:41 PM
  3. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM
  4. Visual Basic C++
    By gussguss in forum C++ Programming
    Replies: 8
    Last Post: 11-20-2001, 10:58 AM