?
Solved

Type Mismatch error

Posted on 2003-02-24
5
Medium Priority
?
321 Views
Last Modified: 2013-12-18
Hello, I create a class but when I try to dyplay the MsgBox I get an Error " Type Mismatch"

it is my code
Declaration:
Class Nombre
    Public Name As String
    Public Pago As Currency
     
    Public Sub calc(x As Integer)
        Me.Pago = 9 * x
    End Sub
     
End Class ' end of the Class Nombre

on the Click event:
Sub Click(Source As Button)
   On Error Goto lblErrs
     
   Dim myNombre As New Nombre
     
   With myNombre
      myNombre.Name =  "Tarzan"
      myNombre.calc(40)                    
   End With
     Msgbox "Name: " +myNombre.Name + "Pago: "+ myNombre.Pago >>>> Here got Type Mismatch Error
     
lblErrs:
     Messagebox "An error has occurred. The error was '" & Error$ &"' code number, " & Err & ".", 0, "Error!"
     Exit Sub    
End Sub

Thank you.

Carlos



0
Comment
Question by:calucho
[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
  • 3
5 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 150 total points
ID: 8012865
Hello Carlos,

try this:

Sub Click(Source As Button)
     On Error Goto lblErrs
     
     Dim myNombre As New Nombre
     
     With myNombre
          myNombre.Name =  "Tarzan"
          myNombre.calc(40)                    
     End With
     Msgbox "Name: " & myNombre.Name & "Pago: " & myNombre.Pago '>>>> Here got Type Mismatch Error
     Exit Sub
     
lblErrs:
     Messagebox "An error has occurred. The error was '" & Error$ &"' code number, " & Err & ".", 0, "Error!"
     Exit Sub    
End Sub

Good luck,
Zvonko

0
 
LVL 7

Expert Comment

by:scottrma
ID: 8012902
You have defined Pago as Currency. You need to convert it to String before it can be printed in a Messagebox:

Msgbox "Name: " + myNombre.Name + "Pago: "+ Cstr(myNombre.Pago)

Regards,

Scott
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8012919
Only for reduction:

Sub Click(Source As Button)
     On Error Goto lblErrs
     
     Dim myNombre As New Nombre
     
     With myNombre
          .Name =  "Tarzan"
          .calc(40)                    
          Msgbox "Name: " & .Name & "Pago: " & .Pago
     End With
     Dim i As Integer
     Exit Sub
     
lblErrs:
     Messagebox "Line#" & Erl & ", ErrorCode:" & Err & "; Error: " & Error, 0, "Error!"
     Exit Sub    
End Sub






0
 

Author Comment

by:calucho
ID: 8012923
Thank you amigo Zvonko.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8012937
Thank you too.

But next time please remember that regular grading is an A.
Give B only if you are dispointed.

See you,
Zvonko

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

777 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