I need help on my recipe code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • erikaslt66
    New Member
    • Feb 2014
    • 6

    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.


    Code:
    Public Class Form1
        Structure Accounts
            Dim membernumber As Integer
            Dim membername As String
            Dim membersurname As String
            Dim memberaccountfull As Boolean
            Dim memberowed As Integer
        End Structure
    
        Dim members(99) As Accounts
        Dim row As Integer
    
    
        Private Sub btndataentry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndataentry.Click
            For Me.row = 0 To 0
                members(row).membernumber = InputBox("Please insert member account number.")
                members(row).membername = InputBox("Please insert member forename.")
                members(row).membersurname = InputBox("Please insert member surname.")
                members(row).memberaccountfull = InputBox("Does member has full account? If yes insert 1, if no insert 0")
                members(row).memberowed = InputBox("Please insert how much member is owed to us.")
                Me.row = Me.row + 1
                lstboxaccounts.Items.Add(row)
    
            Next
    
    
    
        End Sub
    
        Private Sub lstboxaccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxaccounts.SelectedIndexChanged
            row = lstboxaccounts.SelectedIndex.ToString
            txtmembernumber.Text = members(row).membernumber
            txtmembername.Text = members(row).membername + " " + members(row).membersurname
            If members(row).memberaccountfull Then txtmemberaccount.Text = "Y" Else txtmemberaccount.Text = "N"
            txtmemberowed.Text = members(row).memberowed
        End Sub
    End Class
  • erikaslt66
    New Member
    • Feb 2014
    • 6

    #2
    Everything is sorted by now, thanks.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Can you post your solution in case someone else has the same issue?

      Comment

      • erikaslt66
        New Member
        • Feb 2014
        • 6

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

        Code:
        Public Class Form1
        
            Dim recipename As String
            Dim recipeserves As Integer
            Dim ingredients(25) As String
            Dim index As Integer
            Dim ingredientindex As Integer
            Dim ingredientquantity(25) As Integer
            Dim ingredientunit(25) As String
        
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                recipename = InputBox("Please enter your recipe name.")
                recipeserves = InputBox("Please enter serves number for this recipe.")
                index = InputBox("Please enter ingredients number.")
        
                txtnames.Text = recipename
                txtserves.Text = recipeserves
        
                For Me.ingredientindex = 1 To index
                    ingredients(ingredientindex) = InputBox("Please enter ingredient name.")
                    ingredientquantity(ingredientindex) = InputBox("Please enter ingredient quantity for the following ingredient.")
                    ingredientunit(ingredientindex) = InputBox("Please enter ingredient unit for the following ingredient")
                Next
        
                For Me.ingredientindex = 1 To index
                    lstbox.Items.Add(ingredients(ingredientindex))
                    lstbox1.Items.Add(ingredientquantity(ingredientindex))
                    lstbox2.Items.Add(ingredientunit(ingredientindex))
                Next
        
            End Sub
        
        End Class

        Comment

        Working...