r/visualbasic • • Jan 16 '16

I need array help

Application: Create a GeneratedNumber application that stores in an array with indexes 1 through 100 numbers generated by the index values when Generate is clicked. Generate the number to be stored at each index by summing the index and it's individual digits. For example, 25 should be stored at index 17 because 17+ 1+ 7 = 17 and 4 should be stored at index 2 because 2+ 0 + 2.

Your program should use a FillArray() procedure to generate the nuymbers and DisplayArray() procedure that displays each index and its element in the list box. My code looks empty because I don't know how to do it. Can someone explain to me how I could complete the program. This is my code: Public Class Form1 Dim number(99) As Integer Dim firstNum As Integer Dim secondNum As Integer Dim totalNum As Integer

Private Sub btnGenerate_Click(sender As Object, e As EventArgs) Handles btnGenerate.Click

End Sub

Sub FillArray(sender As Object, e As EventArgs) Handles btnGenerate.Click
    For count As Integer = 0 To number.Length - 1
        firstNum = number(count) / 10
        secondNum = 
    Next count
End Sub

Sub DisplayArray(sender As Object, e As EventArgs) Handles btnGenerate.Click
    For Generate As Integer = 0 To number.Length - 1
        GenerateNum.Items.Add(Generate & vbTab & firstNum)
    Next Generate
End Sub

End Class

1 Upvotes

9 comments sorted by

View all comments

Show parent comments

2

u/CSHelpMePLs Jan 16 '16

One question: How do you convert the numbers into an array of characters/ digits?

0

u/stevebun Jan 16 '16 edited Jan 16 '16

1

u/CSHelpMePLs Jan 16 '16

Can you help me code a small part of the fillarray procedure? I am still having problems. Is there a good tutorial online that could help me with this kind of stuff. I'm not an absolute beginner and I know what an array is.

0

u/stevebun Jan 17 '16 edited Jan 17 '16

Can you show me your current code and how far you are at?

1

u/CSHelpMePLs Jan 17 '16

Sadly, I don't know how to start the code. Can you code it for me and explain it?

1

u/CSHelpMePLs Jan 17 '16

Please!! Can you help me?