Solved

User Controls and referencing them

Posted on 2006-07-18
2
167 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal reports vb.net 2 54
SqlServer no dupes 25 38
How to duplicate form in Visual Studio 2015 2 58
VB.net SQLCommandBuilder Insert New Records From DataGridView 3 25
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

856 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