stinger_60284
asked on
Values are blank!?
I have made a program that contains tab pages created on the fly.
Each tab page contains one or more controls created on the fly as well.
My problem is that when I loop through the tab pages, and get those controls, I can't get the values that people entered on those controls.
For example: if in tab A contains textbox control, say txt_control_1, and people enter "123" in that textbox, what I can get only the name of the control, and the value itsself is blank.
Here is my code:
For iCount = 0 To tabCtrl_Contact.TabPages(i TabCount). Controls.C ount - 1
oControl = tabCtrl_Contact.TabPages(i TabCount). Controls(i Count)
oControl.Refresh()
iFieldIndex = 0
If Mid(oControl.Name, 1, 3) <> "lbl" Then
If Mid(oControl.Name, 1, 3) = "rad" Then
If CType(oControl, RadioButton).Checked = True Then
arrName = Split(oControl.Name, "_") ' Format should be: prefix_groupID_index
If UBound(arrName) = 2 Then
iGroupID = arrName(1)
iFieldIndex = arrName(2)
sAnswer = oControl.Text
End If
End If
Else
arrName = Split(oControl.Name, "_") ' Format should be: prefix_groupID_index
If UBound(arrName) = 2 Then
iGroupID = arrName(1)
iFieldIndex = arrName(2)
sAnswer = oControl.Text
End If
End If
sSQL = sSQL & _
"Field Index: " & iFieldIndex & " >> " & sAnswer & vbCrLf
End If
Next
Any ideas what I am missing here?
TIA.
Each tab page contains one or more controls created on the fly as well.
My problem is that when I loop through the tab pages, and get those controls, I can't get the values that people entered on those controls.
For example: if in tab A contains textbox control, say txt_control_1, and people enter "123" in that textbox, what I can get only the name of the control, and the value itsself is blank.
Here is my code:
For iCount = 0 To tabCtrl_Contact.TabPages(i
oControl = tabCtrl_Contact.TabPages(i
oControl.Refresh()
iFieldIndex = 0
If Mid(oControl.Name, 1, 3) <> "lbl" Then
If Mid(oControl.Name, 1, 3) = "rad" Then
If CType(oControl, RadioButton).Checked = True Then
arrName = Split(oControl.Name, "_") ' Format should be: prefix_groupID_index
If UBound(arrName) = 2 Then
iGroupID = arrName(1)
iFieldIndex = arrName(2)
sAnswer = oControl.Text
End If
End If
Else
arrName = Split(oControl.Name, "_") ' Format should be: prefix_groupID_index
If UBound(arrName) = 2 Then
iGroupID = arrName(1)
iFieldIndex = arrName(2)
sAnswer = oControl.Text
End If
End If
sSQL = sSQL & _
"Field Index: " & iFieldIndex & " >> " & sAnswer & vbCrLf
End If
Next
Any ideas what I am missing here?
TIA.
ASKER
I did. In fact, oControl.Refresh() was not there originally.
I added it just to test whether it helped or not, and it didn't.
Any more ideas?
I added it just to test whether it helped or not, and it didn't.
Any more ideas?
Have you stepped through to see if all of the tests are passing?
ASKER
You mean?
I have debugged it, line by line, and still I couldn't grab the values.
It is so weird, because I am 100% sure that I have entered values in those controls.
I have debugged it, line by line, and still I couldn't grab the values.
It is so weird, because I am 100% sure that I have entered values in those controls.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks gdexter, but your code still brings the same result, blank values. :-(
Anymore ideas?
Anymore ideas?
Hmm...
I am assuming that the Cast to get the Radiobutton Checked Property works, so
you could try to cast to the object type when you are getting the Text Property.
sAnswer = DirectCast(oControl, TextBox).Text
or
sAnswer = DirectCast(oControl, RadioButton).Text
I am assuming that the Cast to get the Radiobutton Checked Property works, so
you could try to cast to the object type when you are getting the Text Property.
sAnswer = DirectCast(oControl, TextBox).Text
or
sAnswer = DirectCast(oControl, RadioButton).Text
ASKER
Still not working.
There must be something I miss here.
Again, thanks for your help gdexter.
There must be something I miss here.
Again, thanks for your help gdexter.
ASKER
Gosh, stupid me!!!
Accidentally my code called a procedure that recreate the controls. No wonder the values are always blank.
Than you very much gdexter for all your help.
You are the man!!!
Accidentally my code called a procedure that recreate the controls. No wonder the values are always blank.
Than you very much gdexter for all your help.
You are the man!!!
oControl.Refresh()