|
-
May 5th, 2013, 03:37 PM
#1
Thread Starter
New Member
Need help with school project..
I am currently doing a computing project at school, and am having trouble with some parts of it.
My task is to create a program that will store a recipe name, number of people it will serve and the list of ingredients with their quantities and units.
It also asks that the program should output the recipe name and a new number of people with revised quantities with units for any number of people that the user chooses.
So far for my code I have:
Imports System.IO
Public Class Form1
Private Sub ButtonOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOpen.Click
Dim FileReader As StreamReader
Dim results As DialogResult
results = OpenFileDialog1.ShowDialog
If results = DialogResult.OK Then
FileReader = New StreamReader(OpenFileDialog1.FileName)
IandQ.Text = FileReader.ReadToEnd()
FileReader.Close()
End If
End Sub
Private Sub ButtonSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSave.Click
Dim FileWriter As StreamWriter
Dim results As DialogResult
results = SaveFileDialog1.ShowDialog
If results = DialogResult.OK Then
FileWriter = New StreamWriter(SaveFileDialog1.FileName, False)
FileWriter.Write(IandQ.Text)
FileWriter.Write(RecipeNameSave.Text)
FileWriter.Write(Serves.Text)
FileWriter.Close()
End If
End Sub
Private Sub AmendRecipeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AmendRecipeButton.Click
End Sub
End Class
This code allows me to save and retrieve files but I cannot separate the recipe name or the number of people into separate text boxes from the ingredients.
I also have no clue as to how I can amend the ingredient quantities after a new number of people is chosen.
Any helpful suggestions are appreciated.
-
May 5th, 2013, 03:52 PM
#2
Re: Need help with school project..
I also have no clue as to how I can amend the ingredient quantities after a new number of people is chosen.
I believe it's called arithmetic.
I cannot separate the recipe name or the number of people into separate text boxes from the ingredients.
You don't appear to be trying to do so! Let's just say that reading a file as a single block of text isn't the way to go.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 5th, 2013, 04:07 PM
#3
Thread Starter
New Member
Re: Need help with school project..
 Originally Posted by dunfiddlin
I believe it's called arithmetic.
You don't appear to be trying to do so! Let's just say that reading a file as a single block of text isn't the way to go.
I understand that, but it's how to put it in to the code that I can't do.
As for the separate text boxes, I tried using the 'Split()' function and using an array, I couldn't get either to work.
-
May 5th, 2013, 04:13 PM
#4
Addicted Member
Re: Need help with school project..
Look into the Streamwriter's WriteLine and the Streamreader's ReadLine methods.
Right now, you have:
FileWriter.Write("AAA")
FileWriter.Write("BBB")
Which outputs:
AAABBB
But with Writeline instead:
FileWriter.WriteLine("AAA")
FileWriter.WriteLine("BBB")
You get:
AAA
BBB
Which then you can easily read one line at a time using the Streamreader's Readline method.
-
May 5th, 2013, 04:18 PM
#5
Re: Need help with school project..
I tried using the 'Split()' function and using an array, I couldn't get either to work.
So what happened? Your computer exploded, Superman died? What?
We work with cold, hard detail around these parts. If you can't or won't supply it, we don't help. If you're looking for someone to relieve you of the burden of writing the program you won't find them here, especially for a school project.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|