How is this done now?

  • Thread starter Thread starter vbMark
  • Start date Start date
V

vbMark

A long, long time ago when I programmed in basic, I could have following
lines, for example:

Data "dog,1,yes,brown"
Data "cat,3,yes,white"
Data "horse,1,no,brown"
Data "pig,7,no,pink"
Data "cow,1,no,black"

And then some code (I forget how) to read the lines.

Does anyone know what I'm talking about?

Can something like this be done now in vb.net? How?

Thanks!!
 
Yes, the old Read and Data statements. Those have been gone for a long
time. You could use an array but it is not the same thing. Probably
the best bet would be to store that information in a file and read it
from there.

Chris
 
Yes, the old Read and Data statements. Those have been gone for a long
time. You could use an array but it is not the same thing. Probably
the best bet would be to store that information in a file and read it
from there.

Chris

That's what I figured.

Thanks.
 
I think you mean splitting the items up:

Start a new Windows application & add a button (Button1) to your form

Double-click the button & paste in the following code

Dim strData() As String
Dim sr As New IO.StreamReader(Application.StartupPath & "\Test.txt")
Do While sr.Peek > -1
strData = sr.ReadLine.Split(",")
MessageBox.Show(strData(0) & ControlChars.CrLf & strData(1) &
ControlChars.CrLf & strData(2) & ControlChars.CrLf & strData(3))
Loop
sr.Close()
End Sub

-------------------------------------

Make sure you create a text file (test.txt) in the 'bin' directory & use the
data a showen below:

dog,1,yes,brown
cat,3,yes,white
horse,1,no,brown
pig,7,no,pink
cow,1,no,black

-------------------------------------

Now, when you click on a button you'll get a MessageBox showing the data
like so:

dog
1
yes
brown

Obviously, its up-to-you which way you want to handle the data.

I hope I understood you correctly & the above was of help to you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top