Solved

Conversion type error

Posted on 2011-03-04
7
320 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:plusone3055
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 22

Expert Comment

by:Thomasian
ID: 35042010
    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

0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 35042016
What is the value of txtCustNumber.Text when the error occurs?
0
 
LVL 13

Expert Comment

by:LIONKING
ID: 35043606
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.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 22

Author Comment

by:plusone3055
ID: 35043968
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)
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 0 total points
ID: 35044764
Public Property CustomerID() As String
        Get
            Return strCustomerNumer
        End Get
        Set(ByVal value As String)
            strCustomerNumer = value
        End Set
    End Property
0
 
LVL 22

Expert Comment

by:Thomasian
ID: 35046308
>>Colleciton index must be in the range 1 to the size of hte colleciton
On which code did the error point to?
0
 
LVL 22

Author Closing Comment

by:plusone3055
ID: 35107028
changed from interer to string
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question