5
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by Lida_pink
0

Use the Mod Function to determine if input number is odd or not.
If not, add 1 to number.
Use for loop from 1 to 15 and a variable that is incremented by two with each iteration of the loop.
Take the value from the variable and concatinate into a string variable or textbox, or use the additem method of a list box to display.

Good Luck

0

Could you please write it i mean each steps?
coz I'm not an expert in VB

0

Please post your code that you are working on. Our experts will advice you to improve the same. Don't expect the complete code.

0

Read my reply line by line, sentence by sentence and you will have your answer as you code it up. Then as debasisdas said, if you have any problems with what you have created, then post it with where and what the error is.

Good Luck

0

There is no easy way if you are a beginner in the OOP way, Lida...
Yeah, you post your code and we'll see what we can do.

0

i think this may help you...

first, put 1 listbox(List1), 1 textbox(txtNum) and 1 command button(cmdShow)

and here's the code

Private Sub cmdShow_Click(Index As Integer)
Dim i, num As Integer

num = Val(txtNum.Text)

For i = 1 To num

If i Mod 2 = 1 Then

List1.AddItem i

End If
Next i
End Sub

Odd numbers will show on your listbox. If you want, return it with msgbox. >> Msgbox i

0

Well thanks everyone. I managed to solve it myself.
So here is how I did it:

Private Sub Command1_Click()
Dim x As Integer
x = Val(Text1.Text)
If x Mod 2 = 0 Then
x = x + 1
For i = 1 To 15
Print x
x = x + 2
Next i
Else
x = x + 2
For i = 1 To 15
Print x
x = x + 2
Next i
End If
End Sub

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.