Portal   Forum   Members   Market   Gallery   Events

ugh, visual basic

Discussion in 'Help Forum' started by Jakeman, Jul 15, 2002.

  1. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    maybe you can help me with this haite, or spockirk... have you taken VB? i have to write a program that reads from a text file (.dat). the text file is in this format:

    "John","Male",35
    "Mary","Female",27
    etc...

    my program needs to read from that file, calculate the average age of everyone and calculate how many males and females there are. this is my first program doing something like this and i'm not sure how to start. i know about the string reading functions like Instr, Right, Left, and Mid. I know that Instr returns a number value of how many characters from the beginning until the search string starts. but won't the line breaks in the .dat file and the fact that these are fixed length strings make it so Instr() doesn't work right? :crazy:

    in summary, i know how to do everything needed (open the file, close the file, display results in label control captions, etc) except for how to appropriately extract the right values from the file.
     
  2. Haite

    Haite Forum Moderator

    Joined:
    Jan 29, 2001
    Messages:
    9,325
    Likes Received:
    34
    Market Rating:
    0
  3. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    *me tries code*

    right now it's displaying the info for the last line in the file in the two label controls. so all i should have to do now is add a Select Case structure to check for males and females, add counter variables for males and females, dump the sum of all the ages into a var, and add a counter for number of ages so i can get an average. thx, i think i got it now.
     
  4. Haite

    Haite Forum Moderator

    Joined:
    Jan 29, 2001
    Messages:
    9,325
    Likes Received:
    34
    Market Rating:
    0
    :nod: :D

    I won't do it all for you :nya:.
     
  5. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    write me code 'snatch! :whip: ;)
     
  6. Haite

    Haite Forum Moderator

    Joined:
    Jan 29, 2001
    Messages:
    9,325
    Likes Received:
    34
    Market Rating:
    0
    I'm done with VB classes, it's all Computer Science now.
     
  7. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
  8. Haite

    Haite Forum Moderator

    Joined:
    Jan 29, 2001
    Messages:
    9,325
    Likes Received:
    34
    Market Rating:
    0
    I think you're welcome :nya:.

    Some unneeded little things you did... (I'm assuming you have to do them to please a gay professor though)

    1) VB initializes variables automatically with the Dim statement, so you don't have to assign them a 0 value like you would in C.

    2) My BIGGEST pet peave about how VB is taught... The StartUpPosition property of a form can be set to Centered on Screen, that gay window centering code in the load event isn't necessary even though every damn book and teacher in the world will have you do it.
     
  9. DVD Plaza

    DVD Plaza Peasant

    Joined:
    May 31, 2002
    Messages:
    4
    Likes Received:
    0
    Market Rating:
    0
    Prior to VB4 (or possibly VB5) there was no such option, that's why it was necessary to code it manually.
     
  10. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    startupposition property eh? i'll check that out. thx.
     

Hitometer: 54,381,922 since 1995