Mike, Here is the finished VB program to read your string and display the data in text boxes.<p>Here is what you need to do:<p>- Start a new form
- Add 10 text boxes (do not change their names)
- Add 10 label (do not change their names)
- Ensure that Label1 is next to Text1
- Add 3 command buttons (do not change their names)
-Copy the following code directly and press run<p>'***CODE BELOW***
'***COPY AFTER THIS***<p>Option Explicit<p>Private Function GetData(strTxt As String, tag As String) As String
Dim TagPos As Long
Dim EndPos As Long
GetData = ""
TagPos = InStr(1, strTxt, tag & "=", vbTextCompare)
If (TagPos > 0) Then
EndPos = InStr(TagPos, strTxt, "&")
If (EndPos = 0) Then
GetData = Mid$(strTxt, TagPos + Len(tag) + 1)
Else
GetData = Mid$(strTxt, TagPos + Len(tag) + 1, EndPos - TagPos - Len(tag) - 1)
End If
End If
End Function<p>Private Function FormatString(strTxt As String)
FormatString = Replace(strTxt, "+", " ")
FormatString = Replace(FormatString, "%28", "(")
FormatString = Replace(FormatString, "%29", ")")
' you need to add any more commonly used chars.....
' there might be a better way of doing this function...need to look further into that. but good enough for now.
End Function
Sub Form_load()
Label1.Caption = "First Name"
Label2.Caption = "Last Name"
Label3.Caption = "Address"
Label4.Caption = "City"
Label5.Caption = "State"
Label6.Caption = "Zipcode"
Label7.Caption = "email"
Label8.Caption = "Phone Number"
Label9.Caption = "Insurance"
Label10.Caption = "Submit"<p>With Command1
.Caption = "Clear Data"
End With<p>With Command2
.Caption = "Write To Database"
End With<p>With Command3
.Caption = "Print Data"
End With<p>'You can re-comment the line below when done. This is just to test.
Const strTxt = "FirstName=John&LastName=Smith&Address=123+Fake+Street&City=Fake+Town&State=Some+State&ZipCode=12345&eMail=
[email protected]&PhoneNumber=%28123%29456-7890&Insurance=checkbox&Submit=Pur c hase"<p>'Uncomment below to read from a text file saved on your machine.
'Dim strTxt As String
'Open "postdata.att" For Input As #1
''Open App.Path & "\postdata.att" For Input As #1
'Input #1, strTxt
'Close #1
Text1.Text = FormatString(GetData(strTxt, "FirstName"))
Text2.Text = FormatString(GetData(strTxt, "LastName"))
Text3.Text = FormatString(GetData(strTxt, "Address"))
Text4.Text = FormatString(GetData(strTxt, "City"))
Text5.Text = FormatString(GetData(strTxt, "State"))
Text6.Text = FormatString(GetData(strTxt, "Zipcode"))
Text7.Text = FormatString(GetData(strTxt, "email"))
Text8.Text = FormatString(GetData(strTxt, "PhoneNumber"))
Text9.Text = FormatString(GetData(strTxt, "Insurance"))
Text10.Text = FormatString(GetData(strTxt, "Submit"))<p>End Sub<p>'***Copy END***
'***Code Ends***<p>There ya go!<p>Let me know about the database, it would be a fun project!<p>Greg<p>[ September 24, 2003: Message edited by: Greg ]</p>