Results 1 to 4 of 4

Thread: [RESOLVED] Question

  1. #1

    Thread Starter
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    491

    Resolved [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.

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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,...

  3. #3
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    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.

  4. #4

    Thread Starter
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    491

    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
  •  



Click Here to Expand Forum to Full Width