Absolute Beginner - need some help

JayTech

New member
Joined
Sep 9, 2006
Messages
2
Location
Newcastle, NSW, Australia
Programming Experience
Beginner
Hello everyone, or should I say "Hello World", lol :p

As the title of this thread suggests, I am an absolute beginner to any sort of programming, and this is also my first post here, so sorry if I have put it in the wrong place.

I have only just start learning VB.Net literally a few weeks ago, and to be honest I am having trouble getting my head around it all.

I can do the really really basic stuff, but I have a project to do which much more complicated - for me that is, you guys will find it relatively easy I'm sure.

What I have to do is, I have to make a program for a Plant Nursery which enables them to add details about products into a Windows Form, which then get added to a text file when they click on the "Add Record" button. The program also has to enable them to search for a product by entering in the Product Id then clicking on the "Find Product" button. It also has to count and update how many products are in the file when a new record is added, and also display the entire contents of the file in a listbox when another button is clicked. I have to make the program come up with message boxes when the ProductID, Price, No in Stock and reorder level aren't within a specified range.

I have most of it working now, but getting the last button to work is proving to be an absolute nightmare for me. I have been working on it ALL day Yesterday and ALL day today and I just can't figure out how to make it work. My head is just about to explode! So I thought I would search out a forum and ask for some help.

Here is a screen shot of my program:

ScreenShot.jpg


I have the "List Products" button working ok, and the "Add record" button works ok. I also have the counter working and displaying the No. of products in file correctly.

The problem I am having is that when I click on the "Find Product" button, it will only ever find the product if you type in the first Product ID ie. 123, otherwise it comes up with the error message that I coded in if it can't find a particular Product ID.

I am tearing my hair out trying to get this thing working, so if anyone can help, it would be MUCH appreciated. If you can see something that I have done wrong, put in the wrong place or omitted, could you pleas point it out for me.

Here is the code I have written so far:


VB.NET:
[SIZE=2][COLOR=#0000ff][FONT=Times New Roman]Imports[/FONT][/COLOR][/SIZE][SIZE=2][FONT=Times New Roman] System.IO[/FONT][/SIZE]
[SIZE=2][COLOR=#0000ff][FONT=Times New Roman]Public[/FONT][/COLOR][/SIZE][FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Times New Roman] Form1[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Inherits[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Times New Roman] System.Windows.Forms.Form[/FONT][/SIZE]
 
 
[FONT=Times New Roman][SIZE=2][COLOR=green]'Windows Form Designer Generated Code goes Here[/COLOR][/SIZE][/FONT]
 
 
 
[FONT=Times New Roman][SIZE=3][SIZE=2][COLOR=#008000]'Click on Add Record[/COLOR][/SIZE][/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] cmdAddRecord_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] cmdAddRec.Click[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Make variables[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] NewProdId [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Price [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Descr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] NoInStock [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ReorderLev [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Populate variables[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]NewProdId = Val(txtNewProdId.Text)[/SIZE][/FONT]
[SIZE=2][FONT=Times New Roman]Price = Val(txtPrice.Text)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]Descr = txtDescr.Text[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]NoInStock = Val(txtNoInStock.Text)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ReorderLev = Val(txtReorderlev.Text)[/FONT][/SIZE]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Validate Data[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] NewProdId < 1 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] NewProdId > 5000 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]MsgBox("Product Id must be 1 to 5000")[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Price < 0.05 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Price > 500.0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]MsgBox("Price must be between $0.05 and $500.00")[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] NoInStock < 1 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]MsgBox("Must be at least 1 item in stock")[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] ReorderLev < 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]MsgBox("Reorder Level must be above 0")[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Len(Descr) < 2 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Len(Descr) > 50 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]MsgBox(" Description must have between 2 and 50 characters")[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Write Data to File[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProductsOutFile [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] StreamWriter("C:\Products.txt", [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2])[/SIZE][/FONT]
[SIZE=2][FONT=Times New Roman]ProductsOutFile.WriteLine(NewProdId)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ProductsOutFile.WriteLine(Price)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ProductsOutFile.WriteLine(Descr)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ProductsOutFile.WriteLine(NoInStock)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ProductsOutFile.WriteLine(ReorderLev)[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ProductsOutFile.Close()[/FONT][/SIZE]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Clear variables[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]txtNewProdId.Text = ("")[/SIZE][/FONT]
[SIZE=2][FONT=Times New Roman]txtPrice.Text = ("")[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]txtDescr.Text = ("")[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]txtNoInStock.Text = ("")[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]txtReorderlev.Text = ("")[/FONT][/SIZE]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
 
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Click on List products [/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] cmdListProd_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] cmdListProd.Click[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProductList [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProdId [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Price [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Descr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] NoInStock [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ReorderLev [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][COLOR=#0000ff]Dim [COLOR=black]ProdCount[/COLOR] AsInteger[/COLOR][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Clear List Box[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]lstProd.Items.Clear()[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Read Data from file [/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProductsInFile [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] StreamReader("C:\Products.txt")[/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Do until no more data[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Until[/COLOR][/SIZE][SIZE=2] ProductsInFile.Peek = -1[/SIZE][/FONT]
[SIZE=2][FONT=Times New Roman]ProdId = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]Price = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]Descr = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]NoInStock = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ReorderLev = ProductsInFile.ReadLine()[/FONT][/SIZE]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Display Products in List Box [/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]lstProd.Items.Add(ProdId & vbTab & Descr & vbTab & Price & vbTab & NoInStock & vbTab & ReorderLev)[/SIZE][/FONT]
 
[FONT=Times New Roman][COLOR=green]'Add 1 to Product Count[/COLOR][/FONT]
[FONT=Times New Roman][COLOR=black]ProdCount = ProdCount +1[/COLOR][/FONT]
[/SIZE]
[SIZE=3][FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2]ProductsInFile.Close()[/SIZE][/FONT]
 
[FONT=Times New Roman][COLOR=green]'Display Product Count[/COLOR][/FONT]
[FONT=Times New Roman]lblNoProdInFile.Text = ProdCount[/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Click on Find Products - *not quite working yet*[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] cmdFindProd_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] cmdFindProd.Click[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProdId [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Price [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Descr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] NoInStock [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ReorderLev [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProductsInFile [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] StreamReader("C:\Products.txt")[/SIZE][/FONT]
 
[SIZE=2][FONT=Times New Roman]ProdId = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]Price = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]Descr = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]NoInStock = ProductsInFile.ReadLine()[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]ReorderLev = ProductsInFile.ReadLine()[/FONT][/SIZE]
 
[SIZE=2][FONT=Times New Roman]ProductsInFile.Close()[/FONT][/SIZE]
 
[FONT=Times New Roman][SIZE=2][COLOR=#008000]'Display Product[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] txtProdID.Text = ProdId [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2]lblProdID.Text = ProdId[/SIZE][/FONT]
[SIZE=2][FONT=Times New Roman]lblDescr.Text = Descr[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]lblPrice.Text = Price[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]lblQtyInStock.Text = NoInStock[/FONT][/SIZE]
[SIZE=2][FONT=Times New Roman]lblReorderLev.Text = ReorderLev[/FONT][/SIZE]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][SIZE=2] : MsgBox("ProductID does not exist")[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
 
[FONT=Times New Roman][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/FONT]
[SIZE=2][FONT=Times New Roman][COLOR=#0000ff]End[/COLOR][/FONT][/SIZE][FONT=Times New Roman][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][/FONT]
[/SIZE]


Thankyou in advance,

Jay :)
 
Last edited by a moderator:
You should use a database for that. Access, SQL Server or Oracle to name a few.

Then you should connect, update, execute search and insert records by using ADO.NET.

It would make your program run better, more organized and you would not have the need to play around with TXT files which in the long-run would turn large, slow and hard to manage.

I cant write you the "solution" here as its too big and it would be better for you to learn. Just look around for ADO.NET tutorials and you will start understanding...
 
when you open the application, the first thing you should do is have it (using a StreamReader) count the number of products, and you can do this in the ListProduct's button click event (you've already got the loop there) so when you first load the program in the Form's Load event call the button's click event by "btnListProd.PerformClick" and add an integer variable to be a counter for the loop and there ya go

as for the "find product" part you would need to loop through all of the product's and see if the product ID is the same as the one the user is searching for, if it is display the product and exit the loop: if it's not then continue the loop and if the loop reaches the end of the product's show the the user a MessageBox telling them that the item was not found

also using a database here would help things a lot for ya as well
 
Thanks heaps for that, I appreciate it. It has helpred me get my head around it a bit better. I will now go and see if I can figure out the code to get it working properly.

Cheers,
Jay.



Edit: Thankyou, thankyou, thankyou JuggaloBrotha! After reading your post a few times it all clicked in my head and I was able to figure out how to do it and got the program all working correctly.

As I am so new to programming of any sort, I really appreciate the help. I have also come to the conclusion that sometimes the longer you sit there trying to work something out, sometimes the more you get confused, lol.
 
Last edited:
logic situtations like that get easier the more ya do it, i've been making little apps like the one in this thread for years
 
Back
Top