Link to home
Start Free TrialLog in
Avatar of plusone3055
plusone3055Flag for United States of America

asked on

Conversion type error

Greetings Experts,
Not sure where I went wrong here. I thought my code was pretty solid. My records are adding to my collection but they are not displaying on my main form.  I get my catch error on line 107 (frmMain)
and lines 120 & 120 (frmMain)are givine me conversion type errors..

Conversion from string "" to type 'Integer' is not valid.
Conversion from string "" to type 'Decimal' is not valid.

Yet im not converting either they were declared respectivly in their classes as INteger and decimal.
PLease advise
classes and forms attached  
CustomerClass.txt
PersonClass.txt
PreferredCustomerClass.txt
CustomerInformationModule.txt
frmAdd.txt
frmMain.txt
Avatar of Thomasian
Thomasian
Flag of Philippines image

    Private Sub DisplayData(ByVal pc As PreferredCustomer)
        pc.Address = txtAddress.Text
        pc.City = txtCity.Text
        pc.CustomerID = CInt(txtCustNumber.Text)
        pc.Comments = txtComments.Text
        'pc.DiscountLevel = txtpercent.Text
        pc.FirstName = txtFirstName.Text
        pc.LastName = txtLastName.Text
        pc.Phone = txtPhone.Text
        pc.PurchaseAmount = CDec(txtPurchase.Text)
        pc.State = txtState.Text
        pc.Zip = txtZip.Text
    End Sub

Open in new window

Since the sub is named "DisplayData", I believe you want to show the data in the textbox. If so, that should be
        txtAddress.Text = pc.Address
        txtCity.Text = pc.City
        etc...

Open in new window

Avatar of Wayne Taylor (webtubbs)
What is the value of txtCustNumber.Text when the error occurs?
I think Thomasian has a good point... If you want to display data you should be getting the data from your PreferredCustomer class and displaying it in the textboxes.
Try that out and let us know.
Avatar of plusone3055

ASKER

i reversed it and then it says

Colleciton index must be in the range 1 to the size of hte colleciton

the value i used was 1001

 also when i reversed that
it autogenreated  
txtcustnumber.text = CStr(pc.customerID)
ASKER CERTIFIED SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Colleciton index must be in the range 1 to the size of hte colleciton
On which code did the error point to?
changed from interer to string