Variable inside Textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,
Is it possible to place a variable inside of a textbox and have it
viewed as the value? Or even read in as a string. Here's the
problem... I have a text file I would like to read in to my program.
It is for an email that gets sent out automatically. I would like
anyone to be able to edit the email through the text file. I was
hoping the text file could look something like this:

----------------
Dear "username",

You have reserved a loaner laptop for "begindate". It should be picked
up on "pickupdate" and should be returned on "dropoffdate".
Thanks
Mgmt
----------------

Is this at all possible? Mgmt would like to be able to change the
wording from time to time, however I don't know if it is possible to
read in a string like this and have the variables automatically be
switched to their values. i have been searching for three days and it
appears that this has never been addressed before. Thanks for your
help, even if it is telling me that this is not possible.

Matt
 
You can consider using the Tag property of the TextBox to store the variable
name.

Serge O.
 
Thanks Serge,
I have never used the tag property before. Would I still be able to
keep the variable in my email.txt file? I've tried a couple of
different things with the syntax but it is not working. I am not sure
how to code something like that. MSDN says:
Use the Tag property to assign an identification string to an object
without affecting other property settings or attributes.

For example, you can use Tag to check the identity of a form or control
that is passed as a variable to a procedure.

This only confused me. Thanks for your patience and any possible
examples.

Matt
 
Example:

Sub MyTag()
Me.txtMail.Tag = "EmailAddress"
Me.txtMail.Text = <your value>
End Sub

Or to find which control has the Tag value "EmailAddress", For Each ctl in
Me.Controls ... If ctl.Tag = "EmailAddress" Then...

HTH

Serge
 
The problem is the data always changes. The username gets pulled from
txtusername. Would this still work with this example?
 
That is why I wanted the text file. I was even wondering if I could
read the text file into a string with the text file looking something
like this:

"Dear " & txtusername.text & "," & vbcrlf

"You have reserved a loaner laptop for " & txtbegindate.text & ". It
should be picked
up on " & txtpickupdate.text & " and should be returned on " &
txtdropoffdate.text & "." & vbcrlf
"Thanks" & vbcrlf & "Mgmt"

Is there a way to read that whole text file into a string or textbox
and have it read with the variables filled in?
 
I see,
In this case, you could intruduce key words in your document (text file)
like [Username] and perform a Replace(x,y,z) with the values found in the
controls.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top