Solved

Conversion type error

Posted on 2011-03-04
7
318 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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