I am trying to write a program that will tell me how many calories are in a certain number of eggs, cups of flour, cups of sugar, etc. I have a set number of calories for each of the items (i.e. each egg has 72 calories), but I ask the user to input in a textbox how many of each item the recipe calls for. After they input the quantity, I put the item they chose into a listbox followed by a hyphen and the quantity (i.e. eggs (each) - 2). What I need help with is being able to get the computer to determine where the hyphen is in that String and then reading whatever is following the hyphen into a Double value. Is this even possible?
macdunk11 0 Newbie Poster
Recommended Answers
Jump to PostTry this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim calories As Integer = 0 For i As Integer = 0 To RcpRqrLstBx.Items.Count - 1 Dim tokens() As String = RcpRqrLstBx.Items.Item(i).Split("-") Select Case tokens(0) Case "eggs (each)" calories += 72 * Val(tokens(1)) …
All 4 Replies
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
macdunk11 0 Newbie Poster
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
kingsonprisonic 42 Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.