|
-
Aug 17th, 2001, 06:37 AM
#1
Thread Starter
New Member
get all textbox values at once
Is there any way of looping through every textbox in a form to get thier values.
This is how i have done it in ASP....
For Each objItem In Request.Form
It will save me having to write out a string for every textbox....
saveStr = saveStr & "email=" & email.text
saveStr = saveStr & "firstname=" & firstname.text
saveStr = saveStr & "lastname=" & lastname.text
saveStr = saveStr & "comments=" & comments.text
and so on for over 50 textboxes
Last edited by gingernuutter; Aug 17th, 2001 at 08:08 AM.
-
Aug 17th, 2001, 06:47 AM
#2
New Member
not sure if this is what you meant, but - you can always try control arrays.
so if you had 5 text boxes, as txtBox(0), txtBox(1).... txtBox(4), you could do this:
Dim saveStr as String
Dim i as Integer
For i = 0 to txtBox.Count - 1
saveStr = saveStr & "comments=" and txtBox(i).Text
Next
-
Aug 17th, 2001, 06:51 AM
#3
This should work.
VB Code:
Option Explicit
Dim strText() As String
Private Sub Command1_Click()
Dim ctl As Control
ReDim strText(0)
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ReDim Preserve strText(UBound(strText) + 1)
strText(UBound(strText)) = ctl.Text
End If
Next ctl
End Sub
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
|