473,388 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Type mismatch error

I'm getting an error 13 - Type Mismatch with the following code:

Expand|Select|Wrap|Line Numbers
  1. MsgBox "Total trip miles = " & lngTripMiles & _
  2.                 " and the status miles total = " _
  3.                 & (lngLoadedMiles + lngEmptyMiles + lngBobtailMiles) & ".", "Trip calculation error"
All the variables are defined as Long. What am I doing wrong?
Thanks
Dec 12 '13 #1

✓ answered by zmbd

that is because "Trip calculation error"
is in the position for the button/icon/msgtype

IMHO: It's usually better to build your string first and then insert it into the function.

In anycase, add another comma before the "Trip...", and I prefer to specify the button type; thus, you now have:
Expand|Select|Wrap|Line Numbers
  1. MsgBox "Total trip miles = " & lngTripMiles & _
  2.                 " and the status miles total = " _
  3.                 & (lngLoadedMiles + lngEmptyMiles + lngBobtailMiles) & ".", vbOKOnly, "Trip calculation error"
  4.  
IMHO Ideally you would
Expand|Select|Wrap|Line Numbers
  1. (...)dim strMsg as String
  2. strMsg = "Total trip miles = " & lngTripMiles & _
  3.                 " and the status miles total = " _
  4.                 & (lngLoadedMiles + lngEmptyMiles + lngBobtailMiles) & "."
  5. '
  6. MsgBox strMsg,vbOKOnly,"Trip calculation error"
  7. (...)
This way if you need to you can debug.print the string.

3 1036
zmbd
5,501 Expert Mod 4TB
that is because "Trip calculation error"
is in the position for the button/icon/msgtype

IMHO: It's usually better to build your string first and then insert it into the function.

In anycase, add another comma before the "Trip...", and I prefer to specify the button type; thus, you now have:
Expand|Select|Wrap|Line Numbers
  1. MsgBox "Total trip miles = " & lngTripMiles & _
  2.                 " and the status miles total = " _
  3.                 & (lngLoadedMiles + lngEmptyMiles + lngBobtailMiles) & ".", vbOKOnly, "Trip calculation error"
  4.  
IMHO Ideally you would
Expand|Select|Wrap|Line Numbers
  1. (...)dim strMsg as String
  2. strMsg = "Total trip miles = " & lngTripMiles & _
  3.                 " and the status miles total = " _
  4.                 & (lngLoadedMiles + lngEmptyMiles + lngBobtailMiles) & "."
  5. '
  6. MsgBox strMsg,vbOKOnly,"Trip calculation error"
  7. (...)
This way if you need to you can debug.print the string.
Dec 12 '13 #2
Thanks! I wasn't paying close enough attention to the prompts when I created it.
Dec 12 '13 #3
zmbd
5,501 Expert Mod 4TB
if I had a dollar... (^_^)
Dec 12 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: leslie_tighe | last post by:
Hello, I have a method on a com+ object that is returning an array of objects. I know the array is popluated as calls to check the ubound and lbound show valid values. However, any calls to...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
6
by: shan | last post by:
What is the meaning for the error expression syntax and type mismatch error.I am using turbo c++.can anybody correct the errors in the folowing program. Following program is to find matrix...
1
by: jodyblau | last post by:
I am getting a type mismatch message under strange circumstances. Here's whats going on: 1. I have split the database into a front end and a back end. 2. I have compiled the project. 3. ...
2
by: Rehan | last post by:
Hi there! Please help me out here. I am an inch away from completing my assignment. I am very new to VBA but i have very less time to be efficient at it. I am getting a type mismatch error...
5
by: kjworm | last post by:
Hello Everyone, I have been fighting with a type mismatch error for many hours today and I can't seem to find what the problem is. Hopefully it is more than a missing apostrophe! I have isolated...
7
by: Mike | last post by:
Type Mismatch error I recieve a type mismatch error on the following line of code which is based on a specific date. It does NOT break on all records only "some". The dates for the records...
5
by: Lara1 | last post by:
Hi, I'm a total beginner to VBA, so please bear with me if I seem a bit dense. What I'm Trying to Achieve I'm trying to write a procedure in Excel, which is supposed to - look at the pH...
1
by: sharbha | last post by:
I am experiencing a VBScript runtime error. The error message is: "(0x800A000D)Type mismatch error" Here is my code: <% dim temp temp=session("items") ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.