Solved

Conversion type error

Posted on 2011-03-04
7
315 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
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now