Link to home
Start Free TrialLog in
Avatar of stinger_60284
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(iTabCount).Controls.Count - 1
                oControl = tabCtrl_Contact.TabPages(iTabCount).Controls(iCount)
                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.
Avatar of gdexter
gdexter

Remove this line:
oControl.Refresh()
Avatar of stinger_60284

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?
Have you stepped through to see if all of the tests are passing?
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.
ASKER CERTIFIED SOLUTION
Avatar of gdexter
gdexter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks gdexter, but your code still brings the same result, blank values. :-(

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



Still not working.

There must be something I miss here.

Again, thanks for your help gdexter.
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!!!