|
-
Jan 2nd, 2010, 06:07 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Jan 2nd, 2010, 06:27 AM
#2
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
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jan 2nd, 2010, 06:28 AM
#3
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!
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Jan 2nd, 2010, 06:31 AM
#4
Thread Starter
Hyperactive Member
Re: Question
Thanx Akhilesh and jemidiah
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|