Click here to Skip to main content
16,013,918 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Is .NET that much better than VB6? Pin
Dave Kreskowiak7-Jun-05 13:01
mveDave Kreskowiak7-Jun-05 13:01 
AnswerRe: Is .NET that much better than VB6? Pin
chrismerrill6-Jun-05 17:53
chrismerrill6-Jun-05 17:53 
GeneralRe: Is .NET that much better than VB6? Pin
Christian Graus6-Jun-05 18:18
protectorChristian Graus6-Jun-05 18:18 
GeneralRe: Is .NET that much better than VB6? Pin
chrismerrill6-Jun-05 19:57
chrismerrill6-Jun-05 19:57 
GeneralRe: Is .NET that much better than VB6? Pin
Christian Graus7-Jun-05 11:53
protectorChristian Graus7-Jun-05 11:53 
GeneralRe: Is .NET that much better than VB6? Pin
JoeySmith7-Jun-05 18:25
JoeySmith7-Jun-05 18:25 
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 
Hi, I have been using google to find a way to count all controls and go trough them to find all the TextBox controls and put them into an array of TextBoxes.
I can't seem to find any good way to do this so I was thinking of making a function to count them, but I get an error I just can't get around it seems.

This is how the function looks like:
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

I call the function with 'GetControls(tcMain.Controls)' there tcMain is an TabControl object and all I get is this exception 'System.InvalidCastException'. When I try to call the function with 'GetControls(Me.Controls)' it get it right and count the controls on the form, but when the function finds a TabControl object I get the same exception.

Anyone got any idea what I made wrong, or have any tip on how I can count all controls and "child-controls" I would be more then happy! Smile | :)

Thanks on beforehand! /Joakim
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 
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 

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.