Results 1 to 12 of 12

Thread: Simple question but irritating me

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    36

    Simple question but irritating me

    Hey guys. Just a really simple question. How would I make text appear in a text box from clicking an option button?

    Also, say if these items that I want to be shown in the text box once selected had an assigned price, how would I make it produce the total in the text box?

    This is a college assignment, just so you don't all accuse me of cheating of something, it's nothing too big however so I thought you could help me.

    Thank you

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Location
    UK
    Posts
    199

    Re: Simple question but irritating me

    Hey guys. Just a really simple question. How would I make text appear in a text box from clicking an option button?
    Put the following in your command buttons click event:

    Code:
    me.text1.text = "the information to display"

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    36

    Re: Simple question but irritating me

    Quote Originally Posted by PaulTilley View Post
    Put the following in your command buttons click event:

    Code:
    me.text1.text = "the information to display"
    Ah great thank you. However it only allows me to have one thing in the textbox at a time, I need a list of all the items I click to stay in the text box if that can be done?

  4. #4
    Addicted Member
    Join Date
    Sep 2000
    Location
    UK
    Posts
    199

    Re: Simple question but irritating me

    Try having a look at the listbox control - that may be the one you need for your purposes

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    36

    Re: Simple question but irritating me

    Thank you for the suggestion. However I require them to all be displayed in a text box

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Simple question but irritating me

    To have a textbox display multiple lines

    1) Ensure its MultiLine property is True
    2) Set Scrollbars property to taste
    3) When appending lines of text either prefix or suffix the appended lines with a carriage return (vbNewLine)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    36

    Re: Simple question but irritating me

    Quote Originally Posted by LaVolpe View Post
    To have a textbox display multiple lines

    1) Ensure its MultiLine property is True
    2) Set Scrollbars property to taste
    3) When appending lines of text either prefix or suffix the appended lines with a carriage return (vbNewLine)
    Okay I did your instructions 1 and 2. However what do you mean by the 3rd? I'm very amateur. Stress on the word very.

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Simple question but irritating me

    Quote Originally Posted by Arekkusu View Post
    Okay I did your instructions 1 and 2. However what do you mean by the 3rd? I'm very amateur. Stress on the word very.
    Code:
    Text1.Text = Text1.Text & WhateverIsToBeAppended & vbNewLine
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Simple question but irritating me

    try this
    add commandbutton named Command1
    add Textbox names Text1
    do whay lavolpe said set
    1- multiline to true
    2- scrollbars to vertical (at least) or both if you want
    3- he means this look at code below (example)


    Code:
    Private Sub Command1_Click()
    Dim StrText As String
    StrText = "Test"
    Text1.Text = Text1.Text & StrText & vbNewLine
    End Sub

  10. #10

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    36

    Re: Simple question but irritating me

    Quote Originally Posted by LaVolpe View Post
    Code:
    Text1.Text = Text1.Text & WhateverIsToBeAppended & vbNewLine
    The thing is, there is no set order for the items to be selected, so how would I go about doing this?

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Simple question but irritating me

    If I understand you correctly...

    1) Before adding anything to the textbox, you will want to clear the textbox and then append all the items selected

    2) While you are appending them, also keep a running tally of their costs

    It might look something like this...
    Code:
     ' this would be called upon selection of an option button
    
        Dim sText As String, cSum As Currency
        
        If Option1.Value = True Then ' selected
               sText = sText & Option1.Caption
               cSum = cSum + [price of option1 product]
        End If
        ' etc, etc for each Option button
        
        Text1.Text = sText & vbNewLine & "Total = " & FormatCurrency(cSum)
    If your option buttons are in a control array, i.e., Indexed, then you can use a For:Next loop to iterate thru them & check whether or not they are selected

    You didn't describe how your items are selected or what type of control(s) you are using for that. The Option1 in the sample is just an example & should be replaced as needed
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    36

    Re: Simple question but irritating me

    Ah perfect! Just done it! Thank you very much .
    Well, done the listing part, shall try the total cost thing now

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