Passing a variable to a url

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

I have an input box that is storing the data in a variable. I want to pass
the variable as part of a URL. Basically I have a form with a button to send
a text page which is done via a website. An input box pops up when the
botton is clicked asking the user to input the message. the message is sent
as part of the url to send the page. Everything works except the variable
name appears in the page instead of the actual text.

Thanks in advance for your help!
 
Here is the code:


Private Sub Command24_Click()

On Error GoTo Err_Command24_Click

Dim stPage As String
Dim Message, Title, Default
Dim sAppNme As String


Title = "Message" ' Set title.
Message = "Enter the text message" ' Set prompt.
Default = "" ' Set default.
' Display message, title, and default value.
stPage = InputBox$(Message, Title, Default)

If stPage = "" Then
MessageBox.Show ("Please enter message")
Else
stAppName = "C:\Program Files\Internet Explorer\IEXPLORE.EXE
http://www.website.com/page.html?pager_id=9999999999&message=stPage"
Call Shell(stAppName, 1)

End If



Exit_Command24_Click:


Exit Sub

Err_Command24_Click:
MsgBox Err.Description
Resume Exit_Command24_Click
 
Jerry said:
If stPage = "" Then
MessageBox.Show ("Please enter message")
Else
stAppName = "C:\Program Files\Internet Explorer\IEXPLORE.EXE
http://www.website.com/page.html?pager_id=9999999999&message=stPage"
Call Shell(stAppName, 1)



Try this:

stAppName = _
"C:\Program Files\Internet Explorer\IEXPLORE.EXE " & _
"http://www.website.com/page.html?pager_id=9999999999&message=" & _
stPage

That said, it seems to me you'll need to URLEncode your message. That
function isn't built into VBA, though, so you'll probably have to search the
web for some code, using a search string like "VBA URLEncode" or "VB
URLEncode".
 
That worked! Thank you!

Dirk Goldgar said:
Try this:

stAppName = _
"C:\Program Files\Internet Explorer\IEXPLORE.EXE " & _
"http://www.website.com/page.html?pager_id=9999999999&message=" & _
stPage

That said, it seems to me you'll need to URLEncode your message. That
function isn't built into VBA, though, so you'll probably have to search the
web for some code, using a search string like "VBA URLEncode" or "VB
URLEncode".

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top