|
-
Nov 20th, 2011, 02:13 PM
#1
Thread Starter
Member
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
-
Nov 20th, 2011, 02:18 PM
#2
Addicted Member
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"
-
Nov 20th, 2011, 02:35 PM
#3
Thread Starter
Member
Re: Simple question but irritating me
 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?
-
Nov 20th, 2011, 02:46 PM
#4
Addicted Member
Re: Simple question but irritating me
Try having a look at the listbox control - that may be the one you need for your purposes
-
Nov 20th, 2011, 02:53 PM
#5
Thread Starter
Member
Re: Simple question but irritating me
Thank you for the suggestion. However I require them to all be displayed in a text box
-
Nov 20th, 2011, 02:58 PM
#6
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)
-
Nov 20th, 2011, 03:01 PM
#7
Thread Starter
Member
Re: Simple question but irritating me
 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.
-
Nov 20th, 2011, 03:09 PM
#8
Re: Simple question but irritating me
 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
-
Nov 20th, 2011, 03:10 PM
#9
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
-
Nov 20th, 2011, 03:13 PM
#10
Thread Starter
Member
Re: Simple question but irritating me
 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?
-
Nov 20th, 2011, 03:21 PM
#11
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
-
Nov 20th, 2011, 03:36 PM
#12
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|