Can someone explain to me what I am doing wrong? I am trying to get a word to repeat the number of times as the number input. I tried a list box and a text box and I cant seem to figure it out. I am having trouble with a program I am trying to code. These are the instructions and I am trying to figure it out. Write a program that requests the user to enter a positive integer between 1 and 20 and a word. The program will first use a loop to validate the integer input (refer to example 2 in powerpoint as an example) and then use another loop to display the word the same number of times as the integer input.
For example, if the user enters 5 and “hello”, the result will show the following:
Hint: in the second loop, append the word to the result in each iteration of the loop. For example, if the input is 5, the loop will run 5 times and in each iteration of the loop, the word is repeated once. So if the loop runs 5 times, the word is repeated 5 times.
This is what I have so far:
Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
Dim num As Double = 0 Dim Word As String = "" Dim result As String Word = txtWord.Text num = CDbl(txtNumber.Text) result = Word(CInt(num)) Do While num <= 20 lstResults.Items.Add(result) Loop txtResult.Text = result End Sub