Solved

Values are blank!?

Posted on 2004-10-25
195 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
Question by:stinger_60284
    9 Comments
     
    LVL 4

    Expert Comment

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

    Author Comment

    by:stinger_60284
    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
    Have you stepped through to see if all of the tests are passing?
    0
     

    Author Comment

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

    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
    Thanks gdexter, but your code still brings the same result, blank values. :-(

    Anymore ideas?
    0
     
    LVL 4

    Expert Comment

    by:gdexter
    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
    Still not working.

    There must be something I miss here.

    Again, thanks for your help gdexter.
    0
     

    Author Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    877 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now