Problem Assigning value from array to textbox

I'm getting the error message when I use the dropdown box to pass a value to the database thru a stored proc and return another value.  Through debugging I've determined that the array is indeed getting filled with one value, but when I try to place this value in the textbox I get the error.  Also, when I removed the val() from around the array variable name and just had the .ToString() there, it did not error but passed the text 'Ticket' to the text box, which is the class name?!?

Thanks a bunch for any help,

Argument 'Expression' cannot be converted to type 'Ticket'. 
Exception Details: System.ArgumentException: Argument 'Expression' cannot be converted to type 'Ticket'.
Line 23:      arTx = GetIT.GetTickets(strCustName)
Line 24: 
Line 25(KABOOM):  Me.TicketNo.Text = Val(arTx(0)).ToString()  
Here is entire function:
    Private Sub GetEmployeesTickets(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustNames.SelectedIndexChanged
        Dim GetIT As New DOTIT
        Dim strCustName As String
        Dim arTx As ArrayList
        'strCustName = Val(Me.CustNames.SelectedItem)
        If Page.IsPostBack Then
            strCustName = CustNames.SelectedItem.ToString()
            arTx = GetIT.GetTickets(strCustName)
            Me.TicketNo.Text = Val(arTx(0)).ToString() 
        End If
    End Sub
'Function being called:
Public Function GetTickets(ByVal strCustID As String) As ArrayList
        'pg 271
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("DOTITConnectionString").ConnectionString()
        Dim con As New SqlConnection(connectionString)
        Dim cmd As New SqlCommand("pr_GetTickets", con)
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add(New SqlParameter("@CustID", SqlDbType.VarChar))
        cmd.Parameters("@CustID").Value = strCustID
        Dim arTickets As New ArrayList
        Dim reader As SqlDataReader = cmd.ExecuteReader()
        Do While reader.Read()
              Dim Ticks As New Ticket(reader("TicketID")) 
        Return arTickets
    End Function
End Class
'Ticket class:
Public Class Ticket
    Dim intTicketID As Integer
    Public Sub New(ByVal intTicketID As Integer)                 Me.TicketID = intTicketID
    End Sub
    Public Property TicketID() As Integer
            Return intTicketID
        End Get
        Set(ByVal value As Integer)
            intTicketID = value
        End Set
    End Property
End Class

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does it make a difference on the line that blows up if you actually reference the TicketId property?   Maybe something like   Val(arTx(0).TicketId).ToString().  This may not work unless you CType the array item  like   Val(CType(arTx(0),Ticket).TicketId).  

Another possiblity would be in your Ticket class to override the ToString method to return the TicketId.   Then instead of it returning the word Ticket, it would return the TicketId instead.
Me.TicketNo.Text = CType(arTx(0), Ticket).TicketID.ToString()

insteed of

 Me.TicketNo.Text = Val(arTx(0)).ToString()

You getting error bcoz ... val() function returns decimal type so this need correct Argument

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MoonDoggieAuthor Commented:
Perfect, thanks!
MoonDoggieAuthor Commented:
So I'm trying to understand exactly what is going on here.  Am I passing the class object Ticket within an array then grabbing the property TicketID out of it?  If so is this the cleanest way to do it or should I be just passing the integer value of TicketID in the array?  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.