Re: Convert long number to ascii

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



jonny wrote:
How can i convert a long number to ascii and transmit it through a com
port using mscomm? When I try to send through the com port I receive
and error code 380 Invalid property value. I've checked my
cofiguration of mscomm and it all seems correct but it just doesn't
work. Any help would be greatly appreciated.

Adding the information from your other post, it looks as if what your display wants is two Ascii characters for the device address, then four (or five, if using a DP) for the value.

Assuming you know the address of the device (say, "01") , and you want to display "23.4" on it, try this or variations of it:

Dim AddrNum As Long
Dim Addr As String
Dim ValuNum As Single
Dim Valu As String

AddrNum = 1
ValuNum = 23.4

Addr = Right$("0" & CStr(AddrNum), 2) ' "00" - "99" to two places
Valu = Format$(ValuNum, "000.0") ' "023.4" with leading 0s

MSComm1.Output Addr & Valu

--

Jim Mack
MicroDexterity Inc
www.microdexterity.com
.



Relevant Pages

  • Re: Convert long number to ascii
    ... Since you said that the rest of the MSComm setup looked OK, I assumed that you were opening the port, setting the baud rate and so on. ... Dim AddrNum As Long ... Dim Addr As String ... Dim Valu As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Convert long number to ascii
    ... When I try to send through the com port I receive ... Dim AddrNum As Long ... Dim ValuNum As Single ... Dim Valu As String ...
    (microsoft.public.vb.general.discussion)
  • input file for changing printer config?
    ... For the portmgr.vbs, how can I use an input file for port names/IP addresses? ... dim gDebugFlag ... while iIndex < oArgs.Count ...
    (microsoft.public.windows.server.scripting)
  • Re: SQL Express Command Options
    ... You couldl use "disablenetworkconnections" swith in SQL Express setup ... If you want to change the port the server is listening, ... Dim MachineName As New String) ... Microsoft Online Community Support ...
    (microsoft.public.sqlserver.connect)
  • Re: problem with printing via bluetooth printer adapter
    ... You never set up the COM port anywhere (speed, ... Dim fs As IO.StreamReader ... then sends the stream of the text file to the bluetooth port. ... If ctr = 1024 Then ...
    (microsoft.public.dotnet.framework.compactframework)