-
[RESOLVED] Question
I have made a table, the coding is:
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
n = Val(Text1.Text)
i = 1
Print n & "x" & i & "=" & n * i
i = 2
Print n & "=" & i & "=" & n * i
i = 3
Print n & "=" & i & "=" & n * i
i = 4
Print n & "=" & i & "=" & n * i
i = 5
Print n & "=" & i & "=" & n * i
i = 6
Print n & "=" & i & "=" & n * i
i = 7
Print n & "=" & i & "=" & n * i
i = 8
Print n & "=" & i & "=" & n * i
i = 9
Print n & "=" & i & "=" & n * i
i = 10
Print n & "=" & i & "=" & n * i
End Sub
when a user enter a number it prints the table on the left side of th form. how can i print it on a label and how to clear the print on the label?
thanx all.:)
-
Re: Question
You have to use Label's Caption property to display inside a Label.
eg:
Code:
Label1.caption="Hello"
Label1.Caption=Label1.Caption & vbnewline & " Aash."
Label1.Caption=Label1.Caption & vbnewline & " Learn"
Label1.Caption=Label1.Caption & vbnewline & " the"
Label1.Caption=Label1.Caption & vbnewline & " basics"
Label1.Caption=Label1.Caption & vbnewline & " of"
Label1.Caption=Label1.Caption & vbnewline & " VB6"
Label1.Caption=Label1.Caption & vbnewline & " as soon as possible"
And for a multiplication table, you can use loops like For loop, while loop, etc...
Code:
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
n = Val(Text1.Text)
Label1.Caption = ""
For i = 1 To 10
Label1.Caption = Label1.Caption & vbNewLine & n & "x" & CStr(i) & "=" & CStr(n * i)
Next i
End Sub
Good luck :wave:
-
Re: Question
You would probably want to set the label's Caption property with your text. Print doesn't work with a label. You can clear the label by setting Caption = "". From your code, you could probably stand to go through a beginner's VB6 tutorial first, since you haven't used a loop. There are a bunch of references on these forums (check people's signatures for some) to such tutorials.
Good luck!
-
Re: Question
Thanx Akhilesh and jemidiah :)