Unable to cast object of type 'System.String' to type 'System.Windows.Forms.TextBox'.

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

you can not convert string to textbox.

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80
TextBox1 = ""

The above line will cause this error: Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'. Can easily be fixed by setting the .Text of the TextBox as the String, and not the TextBox it's self.

TextBox1.Text = ""

Without your code that generates the error, it is difficult for someone to exactly recreate it.

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

thanks.
i already solve it.

i have a problem in my array.. it says "Index was outside the bounds of the arrays"

what is the error handled in that problem?
here is my code

For i As Integer = 0 To 3
                        If i = 0 And skillset(i).ToString <> vbNullString Then
                            txtSkills1.Text = skillset(i).ToString
                        End If
                        If i = 1 And skillset(i).ToString <> vbNullString Then
                            txtSkills2.Text = skillset(i).ToString
                        End If
                        If i = 2 And skillset(i).ToString <> vbNullString Then
                            txtSkills3.Text = skillset(i).ToString
                        End If
                        If i = 3 And skillset(i).ToString <> vbNullString Then
                            txtSkills4.Text = skillset(i).ToString
                        End If
Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

>>it says "Index was outside the bounds of the arrays"

This usually occurs when your (i) goes over the Array length/count.
.Here's an example.

Try
            Dim arTemp() As String = {"one", "two", "three"}
            MsgBox(arTemp(3))
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Since Arrays start at 0 not 1, the arTemp(3) is actually Array 4, which is not included in my declared Array. Therefore you will get the error message.

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

i dont get it :(

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

Ok. With the above posted code, using MsgBox(arTemp(0)) , you will get "one", MsgBox(arTemp(1)) will get you "two", and MsgBox(arTemp(2)) will get you "three" from the arTemp String Array.
.Since in my code I had MsgBox(arTemp(3)) , that Array does not exist in arTemp, which should return a "four", therefore you get the error of "Index was outside the bounds of the Array".

Basically saying, that error will let you know when you are trying to locate something that is not there, it is "outside the bounds", bounds meaning Array length/count.

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

how can i trap that error?
if i don't have the value for that array, i will display nothing in my textbox..

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

Change MsgBox(ex.Message) to TextBox1.Clear in the Try/Catch of my previously posted code.

Try
            '// run all code here that can/might cause an error.
        Catch ex As Exception
            '// add code here to correct the error if it does occur.
        End Try
Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

ok i get it.. :) thanks

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

if i don't write any code in catch ex as exception.
the error will not display ..

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

Correct.

Re: Can anyone explain to me whats the meaning of this error? thanks 80 80

thanks its really help.
i feel so upset not solving that error.
i just new in .net programming.
:) thank you so much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.