Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Type Mismatch error

Posted on 2004-10-22
10
Medium Priority
?
280 Views
Last Modified: 2010-05-18
Hello,

I am actually programming this in Visual Basic EmBedded for a handheld PC.  I am trying to communicate over a comm port to a scale.  For some reason i am getting a type mismatch error.  Any ideas? here is the code...   Thank You


Private Sub btnvalider_Click()

Dim pds As String

Dim buffer As String

 

MsComm1.CommPort = 1

MsComm1.Settings = "1200,O,7,1"

MsComm1.Handshaking = comRTS

MsComm1.InputLen = 1

MsComm1.InBufferCount = 8192

MsComm1.RThreshold = 1

MsComm1.SThreshold = 1

MsComm1.DTREnable = True

MsComm1.PortOpen = True

MsComm1.Output = Chr(27)

MsComm1.Output = "T"

Sleep (2000)

MsComm1.Output = Chr(27)

MsComm1.Output = "P"

buffer = ""

Do

    buffer = buffer & CStr(MsComm1.Input)

Loop Until Len(buffer) = 16

 

pds = Mid(buffer(5, 8))

 

If pds = "   0.0 g" Then

    frmpeseeoeuf.shox vbModal

    Me.Hide

End If

 

MsComm1.PortOpen = False

End Sub
0
Comment
Question by:Navicerts
[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
10 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12379960
Probably a typo but I think you meant show on this line:

frmpeseeoeuf.shox vbModal

i.e.
frmpeseeoeuf.show vbModal

0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 2000 total points
ID: 12380056
May be on this line


pds = Mid(buffer(5, 8))


should be

pds = Mid(buffer, 5, 8)
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 12380092
Where do you get this error?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Author Comment

by:Navicerts
ID: 12380124
well, someone emailed me the problem and the code and said the error was when they executed.  I have the handheld and the digital scale and the connection here and i am trying to replicate what he is trying to do.  While i was trying to set it up i figured i would post.

Now that i am setting up i run the program and never get the error.  I think this is because i am not entering the ...
If pds = "   0.0 g" Then

    frmpeseeoeuf.shox vbModal

    Me.Hide

End If


Reason being because he is in France i probally need to change it to If pds = " 0.0kg" or something, working on that now, ill keep you all updated

Thanks

-Navicerts
0
 
LVL 7

Author Comment

by:Navicerts
ID: 12380176
I am asking for the rest of the code so i can get a better idea of what the "real" problem is, ill let you know when i recive it...  If i never do ill split the points :)

-Navicerts
0
 
LVL 5

Expert Comment

by:IThema
ID: 12380226
otherwise u'd get a compiler error.. not a type mismatch...
Could u tell us where the error occurs? There's also a debug option in VBE. Can u tell us what class the variable MsComm1 is an instance of?

Note that you have an 'O' as in 'Option' in:
MsComm1.Settings = "1200,O,7,1"
Maybe it needs a 0 as in Zero.
0
 
LVL 7

Author Comment

by:Navicerts
ID: 12380278
The Comm is the settings for using the communications port (Com1, Com2, exc.).  I added "Microsoft CE Comm Control 3.0" to be able to use these.  I think this is what you were asking (I am not a VB prgrammer tbh )


-Navicerts
0
 
LVL 7

Author Comment

by:Navicerts
ID: 12380321
just loooked it up the O is correct, it refers to the parity for the Comm port...

I am still trying to get the rest of the code so i can be more clear (having trouble filling in the blanks myself).

I will post it as soon as i get it

Thank You


Setting  Description
E Even
M Mark
N (default) None
O Odd
S Space


-Navicerts
0
 
LVL 5

Expert Comment

by:IThema
ID: 12380417
I think EDDYKT is right; you SHOULD change Mid(Buffer(5,8)) into Mid(Buffer, 5, 8) as the parenthesis for the Mid-funtion is:
Mid(String, Start As Long, Optional Length As Long)

By stating Buffer(5, 8) you're actually saying that Buffer is a variable of type Array. A two-dimensional array to be exact. This would indeed cause a type mismatch, because Buffer is declared as a string. The rest of the code treats 'Buffer' correctly, namely as a string.

Cheers
0
 
LVL 7

Author Comment

by:Navicerts
ID: 12383160
Thank you EDDYKT once i got the program they sent me running and replicated thier error, your soultion solved it

-Navicerts
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 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