Click here to Skip to main content
16,014,294 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Is .NET that much better than VB6? Pin
Christian Graus7-Jun-05 18:29
protectorChristian Graus7-Jun-05 18:29 
GeneralNeed som help with a casting error please. Pin
Qvicksilver6-Jun-05 8:22
Qvicksilver6-Jun-05 8:22 
GeneralRe: Need som help with a casting error please. Pin
5150.Net6-Jun-05 10:59
5150.Net6-Jun-05 10:59 
GeneralRe: Need som help with a casting error please. Pin
Qvicksilver6-Jun-05 12:13
Qvicksilver6-Jun-05 12:13 
GeneralRe: Need som help with a casting error please. Pin
Christian Graus6-Jun-05 14:16
protectorChristian Graus6-Jun-05 14:16 
GeneralRe: Need som help with a casting error please. Pin
Qvicksilver7-Jun-05 3:58
Qvicksilver7-Jun-05 3:58 
GeneralRe: Need som help with a casting error please. Pin
Christian Graus7-Jun-05 11:45
protectorChristian Graus7-Jun-05 11:45 
GeneralRe: Need som help with a casting error please. Pin
Qvicksilver9-Jun-05 19:52
Qvicksilver9-Jun-05 19:52 
Yeah I know, I made another test just to check that there was no other code in my program that was messing with this function.

So I made a fresh start, standard windows app. with a TabControl with 2 TabPages, then I added 2 TextBoxes and 1 Label to each TabPage, and a Button on the first TabPage. and then I added this code and get the same error.

<br />
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        GetControls(Me.Controls)<br />
    End Sub<br />
    Public Function GetControls(ByVal cControl As ControlCollection)<br />
        Dim iControls As Integer<br />
        For i As Integer = 0 To cControl.Count - 1<br />
            If TypeOf cControl(i) Is TabControl Then<br />
                MsgBox(cControl(i).Name)<br />
                GetControls(cControl(i).Controls)<br />
            End If<br />
            If TypeOf cControl(i) Is TabPage Then<br />
                MsgBox(cControl(i).Name)<br />
                GetControls(cControl(i).Controls)<br />
            End If<br />
            If TypeOf cControl(i) Is TextBox Then<br />
                iControls += 1<br />
            End If<br />
            If TypeOf cControl(i) Is Label Then<br />
                iControls += 1<br />
            End If<br />
        Next<br />
        MsgBox(iControls)<br />
    End Function<br />


No idea why it wont work, looks like TabControls don't use the same ControlCollection as for example TabPages or something like that.

Thing is that I like to make this function dynamic so I can use it in any situation to check for Controls in an ControlCollection.

Joakim .A - State: VB6 -> VB.NET
GeneralRe: Need som help with a casting error please. Pin
Qvicksilver9-Jun-05 20:09
Qvicksilver9-Jun-05 20:09 
GeneralRe: Need som help with a casting error please. Pin
Christian Graus13-Jun-05 12:03
protectorChristian Graus13-Jun-05 12:03 
GeneralRe: Need som help with a casting error please. Pin
KaptinKrunch9-Jun-05 9:20
KaptinKrunch9-Jun-05 9:20 
GeneralRe: Need som help with a casting error please. Pin
KaptinKrunch9-Jun-05 9:21
KaptinKrunch9-Jun-05 9:21 
GeneralRe: Need som help with a casting error please. Pin
Qvicksilver9-Jun-05 19:59
Qvicksilver9-Jun-05 19:59 
GeneralMDI FORMS HELPPP! Pin
Josh1991186-Jun-05 8:21
Josh1991186-Jun-05 8:21 
GeneralRe: MDI FORMS HELPPP! Pin
Rizwan Bashir6-Jun-05 22:12
Rizwan Bashir6-Jun-05 22:12 
GeneralRe: MDI FORMS HELPPP! Pin
Anonymous7-Jun-05 2:31
Anonymous7-Jun-05 2:31 
GeneralSudden crash Pin
vishalmishra6-Jun-05 7:51
vishalmishra6-Jun-05 7:51 
GeneralRe: Sudden crash Pin
Christian Graus6-Jun-05 14:17
protectorChristian Graus6-Jun-05 14:17 
GeneralAxtivex controls Pin
smita_roy6-Jun-05 3:09
smita_roy6-Jun-05 3:09 
GeneralRe: Axtivex controls Pin
Rizwan Bashir6-Jun-05 3:29
Rizwan Bashir6-Jun-05 3:29 
Generalrandom files..... Pin
virtual_manu6-Jun-05 1:32
virtual_manu6-Jun-05 1:32 
GeneralRe: random files..... Pin
toxcct6-Jun-05 1:48
toxcct6-Jun-05 1:48 
GeneralRe: random files..... Pin
Rizwan Bashir6-Jun-05 3:33
Rizwan Bashir6-Jun-05 3:33 
GeneralRe: random files..... Pin
virtual_manu7-Jun-05 5:14
virtual_manu7-Jun-05 5:14 
GeneralRe: random files..... Pin
Rizwan Bashir7-Jun-05 22:54
Rizwan Bashir7-Jun-05 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.