Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Values are blank!?

Posted on 2004-10-25
9
Medium Priority
?
207 Views
Last Modified: 2010-04-23
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.
0
Comment
Question by:stinger_60284
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 4

Expert Comment

by:gdexter
ID: 12402620
Remove this line:
oControl.Refresh()
0
 

Author Comment

by:stinger_60284
ID: 12402709
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
 
LVL 4

Expert Comment

by:gdexter
ID: 12402747
Have you stepped through to see if all of the tests are passing?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:stinger_60284
ID: 12402764
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
 
LVL 4

Accepted Solution

by:
gdexter earned 1000 total points
ID: 12402898

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
 

Author Comment

by:stinger_60284
ID: 12403127
Thanks gdexter, but your code still brings the same result, blank values. :-(

Anymore ideas?
0
 
LVL 4

Expert Comment

by:gdexter
ID: 12403316
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
 

Author Comment

by:stinger_60284
ID: 12403369
Still not working.

There must be something I miss here.

Again, thanks for your help gdexter.
0
 

Author Comment

by:stinger_60284
ID: 12403541
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question