Solved

User Controls and referencing them

Posted on 2006-07-18
2
168 Views
Last Modified: 2010-04-23
Hi there, I have a user control called Rate.  Rate is many text boxes, and I have a public function within rate called get_Rate which returns an integer relating to the values in all the text boxes.  i.e. if i know the rate_ID i know the values of all the boxes in the Rate control.

On any given form many instances of the control can be created programatically.

I am at a point in my code where i need to cycle through all the controls on a page, the user control and text boxes, combos etc.

    'Standard structure for recording an entry
    Public Structure TrackData
        Dim Ref As Integer
        Dim Data As String
    End Structure

    Public Sub Capture(ByRef pArray As ArrayList, ByRef pPanel As Panel)
        'Put all data into an array as a benchmark for checking against later.
        pArray.Clear() 'delete everything from current array
        Dim td As New TrackData
        Dim ctrl As Control
        For Each ctrl In pPanel.Controls
            If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Then
                td.Ref = ctrl.Handle
                td.Data = ctrl.Text
                pArray.Add(td)
            End If
            If TypeOf ctrl Is Rate Then
                td.Ref = ctrl.Handle
                td.Data = ctrl.get_Rate()
            End If
        Next
    End Sub

The piece of code errors on ctrl.get_Rate.  This is a public function however!

How do i get around this??

Many thanks, 500 points on offer!
0
Comment
Question by:DavidGreenfield
[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
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 17128551
Hi DavidGreenfield,

td.Data = Ctype(ctrl,Rate).get_Rate()

Perhaps

Tim Cottee
0
 

Author Comment

by:DavidGreenfield
ID: 17128635
Yes that works!  I hadn't realised you could do that for a user control!

Many thanks, 500 points on the way!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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