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 :)
Re: Simple question but irritating me
Quote:
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"
Re: Simple question but irritating me
Quote:
Originally Posted by
PaulTilley
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?
Re: Simple question but irritating me
Try having a look at the listbox control - that may be the one you need for your purposes
Re: Simple question but irritating me
Thank you for the suggestion. However I require them to all be displayed in a text box :)
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)
Re: Simple question but irritating me
Quote:
Originally Posted by
LaVolpe
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.
Re: Simple question but irritating me
Quote:
Originally Posted by
Arekkusu
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
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
Re: Simple question but irritating me
Quote:
Originally Posted by
LaVolpe
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?
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
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 :)