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.
stinger_60284Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdexterCommented:
Remove this line:
oControl.Refresh()
0
stinger_60284Author Commented:
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?
0
gdexterCommented:
Have you stepped through to see if all of the tests are passing?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

stinger_60284Author Commented:
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.
0
gdexterCommented:

Try this and see if you still have a problem:

  Dim oControl as Control

   For Each oControl In tabCtrl_Contact.TabPages(iTabCount).Controls
         iFieldIndex = 0
         If Not (TypeOf (oControl) Is Label) Then
               If (TypeOf (oControl) Is RadioButton)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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stinger_60284Author Commented:
Thanks gdexter, but your code still brings the same result, blank values. :-(

Anymore ideas?
0
gdexterCommented:
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



0
stinger_60284Author Commented:
Still not working.

There must be something I miss here.

Again, thanks for your help gdexter.
0
stinger_60284Author Commented:
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!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.