Some Visual Basic Questions

Capone

Senior member
Jan 28, 2004
371
0
0
I ran into a few problems with my vb programs.

1. I'm reading data from a file and the record stops when there is a 0 on 2 straight lines, then the next record starts.
So basically something like this
Jim
9
7
0
0
Joe
8
0
0

How do I know when the next record begins? right now I'm trying to do it with nested if's but I'm only getting the first record.

2. The next one I'm trying to do is to print this in a listbox

*******
*****
***
*

I have the nested loops giving me the right amount of stars but I'm getting 1 per line because the me.lstOutput.Items.Add("*") goes to a new line after each one. How do I fix this?

I'd put the code on here but I forget the
Code:
 command to do it.
 

xchangx

Golden Member
Mar 23, 2000
1,692
1
71
recursive function, read (read(line)).

Edit:
So in your main read function, call the read function again for the next line.
 

OulOat

Diamond Member
Aug 8, 2002
5,769
0
0
It doesn't have to be recursive, although it's preferred. A while loop will do if you feel more comfortable.
bool readLine1 = true
string line1, line2

do
{
..if readLine1
....line1 = readLine(File)

..if line1=0
..{
....line2 = readLine(File)
....if line2 = 0
......Do whatever you need for new record
....else
......Do whatever you need for current record
......line1 = line2
......readLine1 = false
..}
..else
....Do whatever you need for current record
....readLine1 = true
} while (line1 != null)


2) Why not just pass it a string of ****** instead of just one *? I believe period (.) is to concat strings, so string1="23" and string2="45" then string3 = string1.string2 = "2345"