473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I need help on my recipe code

Hi, I have an assigned task to do the recipe program in school, I have been trying to solve my program in hours, but with little success... It is difficult to make it for me, because there is few problem to sort out. Firstly, the problem is that i want my program to store data one time, and then show it in textbox's fields by selecting it at lstbox. Well I did have an array "For Me.row = 0 to 0" so it will do this one time but i can't make the counter work("row = +1") so next time it will do the same but in lstbox there will be second line not 0 but 1 with data that i stored in array second time. But apparently i have no idea as i have no experience in this thing. Any help would be really appreciated. Thanks. If you need any pics of the interface tell me, i will post it.


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Structure Accounts
  3.         Dim membernumber As Integer
  4.         Dim membername As String
  5.         Dim membersurname As String
  6.         Dim memberaccountfull As Boolean
  7.         Dim memberowed As Integer
  8.     End Structure
  9.  
  10.     Dim members(99) As Accounts
  11.     Dim row As Integer
  12.  
  13.  
  14.     Private Sub btndataentry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndataentry.Click
  15.         For Me.row = 0 To 0
  16.             members(row).membernumber = InputBox("Please insert member account number.")
  17.             members(row).membername = InputBox("Please insert member forename.")
  18.             members(row).membersurname = InputBox("Please insert member surname.")
  19.             members(row).memberaccountfull = InputBox("Does member has full account? If yes insert 1, if no insert 0")
  20.             members(row).memberowed = InputBox("Please insert how much member is owed to us.")
  21.             Me.row = Me.row + 1
  22.             lstboxaccounts.Items.Add(row)
  23.  
  24.         Next
  25.  
  26.  
  27.  
  28.     End Sub
  29.  
  30.     Private Sub lstboxaccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxaccounts.SelectedIndexChanged
  31.         row = lstboxaccounts.SelectedIndex.ToString
  32.         txtmembernumber.Text = members(row).membernumber
  33.         txtmembername.Text = members(row).membername + " " + members(row).membersurname
  34.         If members(row).memberaccountfull Then txtmemberaccount.Text = "Y" Else txtmemberaccount.Text = "N"
  35.         txtmemberowed.Text = members(row).memberowed
  36.     End Sub
  37. End Class
  38.  
Feb 15 '14 #1

✓ answered by erikaslt66

Basically, I have re-done all coding and changed the array , it is not structure any more, it is 1-d array.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Dim recipename As String
  4.     Dim recipeserves As Integer
  5.     Dim ingredients(25) As String
  6.     Dim index As Integer
  7.     Dim ingredientindex As Integer
  8.     Dim ingredientquantity(25) As Integer
  9.     Dim ingredientunit(25) As String
  10.  
  11.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  12.         recipename = InputBox("Please enter your recipe name.")
  13.         recipeserves = InputBox("Please enter serves number for this recipe.")
  14.         index = InputBox("Please enter ingredients number.")
  15.  
  16.         txtnames.Text = recipename
  17.         txtserves.Text = recipeserves
  18.  
  19.         For Me.ingredientindex = 1 To index
  20.             ingredients(ingredientindex) = InputBox("Please enter ingredient name.")
  21.             ingredientquantity(ingredientindex) = InputBox("Please enter ingredient quantity for the following ingredient.")
  22.             ingredientunit(ingredientindex) = InputBox("Please enter ingredient unit for the following ingredient")
  23.         Next
  24.  
  25.         For Me.ingredientindex = 1 To index
  26.             lstbox.Items.Add(ingredients(ingredientindex))
  27.             lstbox1.Items.Add(ingredientquantity(ingredientindex))
  28.             lstbox2.Items.Add(ingredientunit(ingredientindex))
  29.         Next
  30.  
  31.     End Sub
  32.  
  33. End Class
  34.  

3 1791
Everything is sorted by now, thanks.
Feb 16 '14 #2
Rabbit
12,516 Expert Mod 8TB
Can you post your solution in case someone else has the same issue?
Feb 16 '14 #3
Basically, I have re-done all coding and changed the array , it is not structure any more, it is 1-d array.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Dim recipename As String
  4.     Dim recipeserves As Integer
  5.     Dim ingredients(25) As String
  6.     Dim index As Integer
  7.     Dim ingredientindex As Integer
  8.     Dim ingredientquantity(25) As Integer
  9.     Dim ingredientunit(25) As String
  10.  
  11.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  12.         recipename = InputBox("Please enter your recipe name.")
  13.         recipeserves = InputBox("Please enter serves number for this recipe.")
  14.         index = InputBox("Please enter ingredients number.")
  15.  
  16.         txtnames.Text = recipename
  17.         txtserves.Text = recipeserves
  18.  
  19.         For Me.ingredientindex = 1 To index
  20.             ingredients(ingredientindex) = InputBox("Please enter ingredient name.")
  21.             ingredientquantity(ingredientindex) = InputBox("Please enter ingredient quantity for the following ingredient.")
  22.             ingredientunit(ingredientindex) = InputBox("Please enter ingredient unit for the following ingredient")
  23.         Next
  24.  
  25.         For Me.ingredientindex = 1 To index
  26.             lstbox.Items.Add(ingredients(ingredientindex))
  27.             lstbox1.Items.Add(ingredientquantity(ingredientindex))
  28.             lstbox2.Items.Add(ingredientunit(ingredientindex))
  29.         Next
  30.  
  31.     End Sub
  32.  
  33. End Class
  34.  
Feb 17 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ali | last post by:
I am in great need of code that will make a dome. I would like the inputs to be similar to that of the sphere. ie: pos=(x0, y0, z0) radius = R color = (r,g,b) etc. I am using VPython of...
1
by: Cibulya Dmitriy | last post by:
Hi All, I want to catch the next MSSQL error in my SQL code with following continue calculations Server: Msg 17, Level 16, State 1, Line 1 SQL Server does not exist or access denied.
34
by: Mark Kamoski | last post by:
Hi-- Please help. I need a code sample for bubble sort. Thank you. --Mark
2
by: Mark Kamoski | last post by:
Hi Everyone-- Please help. I need a code sample for merge sort. Thank you. --Mark
1
by: Riyadh Hossain | last post by:
I am developing USPS shipping API for my site. All the work is going on testing phase. My site uses PHP/MySQL. Now I am working on USPS tracking/confirm. I can send request and get responses from...
0
by: ravibrl | last post by:
Hey I need c++ code to access a webpage and download some software. If I execute that it should download that software and it should install it in my system. Give suggestions how to write that code...
3
by: dee vee bee | last post by:
this is my project i need a code that will show like this.. "first number __" "second number ___" "choose operation: addition..subtraction..multiplication..division" "the answer is ___" the...
1
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.