Reputation: 335
i wanted to make the data appear in the text box but i recived this error "Unable to cast object of type 'System.String' to type 'System.Windows.Forms.TextBox" please help
txtVendorFAX = daPo.Tables("vendor").Rows(i).Item(3)
Upvotes: 0
Views: 6195
Reputation: 27342
You can only assign a string to the .Text
property of a Textbox
.
The answers given so far do not compile with Option Strict On.
You should use:
txtVendorFAX.Text = daPo.Tables("vendor").Rows(i).Item(3).ToString
You should also make sure you have Option Strict Turned On: http://www.codinghorror.com/blog/2005/08/option-strict-and-option-explicit-in-vbnet-2005.html
Upvotes: 0
Reputation: 1
use .Text
property of the textbox by using following code
txtVendorFAX.Text = daPo.Tables("vendor").Rows(i).Item(3)
a textbox is a Textbox
, not a string. This is why you are getting the error
Unable to cast object of type 'System.String' to type 'System.Windows.Forms.TextBox
Upvotes: 0
Reputation: 509
Try this:
txtVendorFAX.Text = Convert.ToString(daPo.Tables("vendor").Rows(i).Item(3))
Upvotes: 1
Reputation: 5545
Try this instead:
txtVendorFAX.Text = daPo.Tables("vendor").Rows(i).Item(3)
Upvotes: 2