APPLIES TO
• Microsoft ADO.NET (included with the .NET Framework)
• Microsoft ADO.NET 1.1
• Microsoft Visual Basic .NET 2002 Standard Edition
• Microsoft Visual Basic .NET 2003 Standard Edition
----------
Could that be an issue?
by "text tables" do you mean multi-line textbox? I was asking about database, due to possible homework assignment. I did a project similar to this using a text file it uses a picbox, a combobox, 4 labels and a multiline textbox here are a couple of screenshots of the program the first is the program first starts and the second is when a selection is selected.
the best part of using a text file in this scenario is, I don't have to worry about having to package a database in deployment.
Yes that is almost exactly what I am trying to do.
How do you get the picture to display? I have the picture in an access database and cannot get them to show?
Also how do I embed the data into the program. When I try and run the built application on a usb or another computer it wont work and says the database is missing.
Database programming is great. trying to deploy one is horror. you usually have to do it with sql(whether it be mySQL, postgreSQL, or the like. meaning no access database) and have to include a sqlserver with your package.
That is why I try to stay away from them when necessary. This project is a good example when one is not needed.
Have you ever used StreamReader, StreamWriter from the IO class? The program I have also uses arrays.
Ive been here all day lol, and all yesterday, and the day before. Ill be on for another 6 hours. and some time tomorrow.
Is using this read and write thing something relatively simple and quick? If not thats ok. What ever I need to do to get my program basically exactly like yours except on a different topic.
Lol I must have refreshed this forum about 200 times now. And with the other forums in which the responses have been far off..
for some reason I don't remember this being in Data Access area and my post didn't get posted so here is another. First thing is set up a text file almost like you would a database.
For example, I have mine with the following:
imagename.jpg
president name
spouse name
place of birth
age of inauguration
number of terms
date of birth
date begin term
date end term
this is done for each item and item in my case is president
then on to the programming part
set up arrays to hold each
set up streamreader
setup loop to read textfile
fill combobox with another loop
initialize labels, textbox with selected value from combobox
of course there is more to it than this, but this gives you an idea.
I have finished commenting the program I wrote for my son and added an About box. If you are like me and learn by example then this could help you.
I'm not the best at explaining things, but I'll do the best I can.
First set up the text file that will hold all the data just like I showed in my last post. Then design your app.
Are you using a book, course or what to go by to learn VB.NET?
you are going to use arrays in this project. For example I have 9, (8 string, 1 integer)
VB.NET:
Private _strPicName(42) As String
I have 4 other variable also string used in storing filename of image, filename of text file, application path, and modified app path.
purpose of the app path is that no matter where you deploy it, it will be fine
VB.NET:
AppPath = My.Application.Info.DirectoryPath
In the Form_Load section
declare the following variables:
VB.NET:
Dim objReader as StreamReader
AppPath = My.Application.Info.DirectoryPath
two counters intCount, intFill and initialize both to zero
(I included a file not found error message, but isn't necessary for operation of program)
(put all pics, txt file in resources folder in solution explorer)
remember the application path and the modified app path variables declared earlier
we have to do this to take out \bin\ at end of path because we will be adding \Resources\and text file or image later
Next setup an If statement to check if text file exist.
If it doesn't we need to show an error message and close the app, otherwise, contine with a While statement to read the text file until no more can be read into the arrays and as with any loop don't forget the counter to prevent infinite loop.
When done with this loop close the SreamReader
VB.NET:
objReader.Close()
Next we need to do something with the data extracted from the text file
here I opted to start with filling the combobox with the presidents name
then from there things change from Form_Load to ComboBox1_SelectedIndexChanged event
in this event declare more variables
a selected variable for the selected item since each item is a number
this is an integer
also I have 4 message variables all string
initialize selected to combobox1.selectedIndex
setup if statement
since no president is selected in the beginning
VB.NET:
if intSelected greater than -1
do the following
this example
initialize age label = age array (intSelected)
do this for each textbox, label or whatever control you are using
This should get you started
if any of this is seems confusing
you can start it and let me know how far you got, or tell me what you need help with and I'll try to explain it better.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.