View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chet Chet is offline
external usenet poster
 
Posts: 88
Default Is it possible to send a "variable" to a userform text box?

On Jan 30, 12:47*pm, FSt1 wrote:
hi
use the inputbox method ie....
dim v as string
v= inputbox("enter something")
textbox1.value = v

since you didn't post any code, i'm not sure just how you would work it in..
look up inputbox in vb help for more info.

Regards
FSt1



"Chet" wrote:
I have previously sent fixed values to a userform text box but is it
possible to have my code take some user input then feed that user
input to a userform text box during the same run of the code? *In
other words my text box could say "Program will run for location xxxx"
where xxxx is the variable that can change with each run of the code?


Thanks,
Chet- Hide quoted text -


- Show quoted text -


A follow-up question if I may. I did what you said and created the
variable to feed the textbox but the variable is not showing up in the
textbox when the form is displayed when I run the code. Possibly i am
doing it in the wrong sequence or section of code. Where should I put
the code you mentioned?

Right now I have this for my "form code" (shown below)... Textbox3 is
the variable that should be feeding the textbox. I actually created
the variable called FormTextToShow in the main vba module that calls
up the form with this code.

FormTextToShow = "Program will run for location " & Location & " for
month of " & MonthAlpha & " " & TargetYear

I made "FormTextToShow" a Public variable in the main module also in
order to pass it to the form code. The problem is I run the main code
and the variable FormTextToShow does not show up. I just get a blank
textbox showing up on my form. (I did do a step-through it test and
ran the code and the FormTextToShow variable did show up then in my
textbox3.)

What am I doing wrong? Thx much... Chet


Private Sub CommandButton1_Click()
TextBox3.Value = FormTextToShow
TextString1 = TextBox3.Text
PrelimStatus = OptionButton1.Value
FinalStatus = OptionButton2.Value
MinMinutesToKeep = TextBox2.Text
FilterOut = CheckBox1.Value
SaveToDesktop2 = OptionButton3.Value
SaveToMyDocs2 = OptionButton7.Value
SaveToFltSched = OptionButton8.Value
SaveToGeneral = OptionButton4.Value
SaveNo = OptionButton6.Value
Unload FltSchedAnalysis
End Sub