Write a VB program to collect a positive integer from the user and list all the integers in a multiline textbox.
Have a look at Print Even numbers upto n
Refer Factorial of a Number also.
(A)Program Design :
If found any errors while running your VB program, please note it on Comment section.
Have a look at Print Even numbers upto n
Refer Factorial of a Number also.
(A)Program Design :
(B) Property(Controls Used) :
- One Label
- 2 Text Box (One is for entering number and the other is to get the output)
- One Command button
(C) Attaching Code to the Object :
Private Sub Command1_Click() Dim num If Text1.Text <> "" Then num = CInt(Text1.Text) If num < 0 Then MsgBox "Enter only positive integer number" Text1.Text = "" Text1.SetFocus Else For i = 1 To num - 1 If i < num - 1 Then Text2 = Text2 & i & "," Else Text2 = Text2 & i & "," End If Next Text2.Text = Text2.Text & num & "," Text1.Text = "" Text2.SetFocus End If Else MsgBox "Enter the number" Text1.SetFocus End If End Sub |
(D) Output :
(E) Errors :
====================================================================
No comments:
Post a Comment