3 Replies - 2499 Views - Last Post: 10 September 2010 - 03:06 PM Rate Topic: -----

#1 Guest_jim*


Reputation:

Textbox to Output Multiple Lines

Posted 09 September 2010 - 05:40 PM

I just started VB6 and I'm trying to make a program that acts as a ticket vending machine. It lets the user select an item through a listbox and than the number of purchases through option bubbles. And there's a button where when the user presses it, it will give them an invoice.

I'm having problem with the last part and outputting the data. How do you get it so that a textbox can output multiple lines? And how do you output the option bubble and listbox selection?

Private Sub Ticket_Click(Index As Integer) 

Price = 12.75      

    Select Case Index    
        Case 0
            Sum = Price
        Case 1
            Sum = Price * 2
        Case 2
            Sum = Price * 3
        Case 3
            Sum = Price * 4
    End Select

Label4.Caption = Sum 

    If Check1.Value = 1 Then 
        Label4.Caption = Sum - (Sum * 0.2)
    End If

End Sub

Private Sub Command1_Click()

Text1.Text = "Ticket        Price"

End Sub


Thanks

This post has been edited by macosxnerd101: 09 September 2010 - 05:50 PM
Reason for edit:: Title renamed to be more descriptive. Please respect rule #4 of this forum.


Is This A Good Question/Topic? 0

Replies To: Textbox to Output Multiple Lines

#2 Guest_jim*


Reputation:

Re: Textbox to Output Multiple Lines

Posted 09 September 2010 - 06:25 PM

Text1.Text = Text1.Text & vbCrLf & List1.Text


So I figured out how to output the listbox data. But am still trying to figure out how to put the output of the option bubble next to it so it looks like

Ticket ------ Price
Name ------- $30
Was This Post Helpful? 0

#3 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Textbox to Output Multiple Lines

Posted 10 September 2010 - 02:32 PM

A quick idea is to define a string of spaces of length of, let's say 10. Ticket has 6 characters, so price will be on 16th position.

text1.Text = text1.Text & vbCrLf & List1.Text & Left(sSpacesString, Len(sSpacesString) + 6 - Len(List1.Text)) & CStr(Check1.Value)


Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: Textbox to Output Multiple Lines

Posted 10 September 2010 - 03:06 PM

Another option is to use tabs in your string for some basic formatting. Something like below for example.


Dim strText as string
strText = "Ticket" & vbtab & vbtab & "Price" 
strText = strText & List1.text & vbtab & vbtab & cstr(sum)
Text1.text = strText

This post has been edited by maj3091: 10 September 2010 - 03:07 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1