Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: Human on November 18, 2018, 03:29:01 PM
-
Hi
why can't cypress to handle chr(0) as string?
I need string hexadecimal NULL to pass it to a function, but my impression is, cypress can't this.
'Cypress example:
strTest = chr(0)
len(strTest) 'result: 0
isempty(strTest) 'result: false
isnull(strTest) 'result: false
strTest = "" 'result: true
'VBA example:
strTest = chr(0)
len(strTest) 'result: 1
isempty(strTest) 'result: false
isnull(strTest) 'result: false
strTest = "" 'result: false
strTest = vbNullChar 'result: true
In MS Excel VBA the function works fine, with cypress doesn't it.
Can anyone help me?
Thanks,
Robert
-
Looks like cypress can not handle the CHR(0)
if you try
strTest = &H00
len(strTest) gives the result 1
-
Hi
at me the length of &H00 is 2 and in Hex-Editor view the result is it character 30.
I need character 00.
Again a dead end, but I`m not giving up ;)
Thanks
Robert
-
Hi Robert,
did two test's, see screenshots.
-
and a third one, seems to be ok.
-
Hi
I didn't used the CStr function. Sorry, a mistake of myself.
I saved always to a file and looking the results with an Hex-Editor.
So i can see what cypress is passing.
Perhaps the len function is not the right, around to see, if cypress can handle this or not.
Rather a byte length function for character.
I tried with following API and i think the matter is clear:
Declare Function VarPtr Lib "msvbvm60.dll" (ByVal lpObject As String) As Long
Declare Function SysStringByteLen Lib "oleaut32.dll" (ByVal pBStr As Long) As Long
strTest1 = Chr(1)
strTest2 = Chr(0)
MsgBox SysStringByteLen(VarPtr(strTest1)) 'result: 2
MsgBox SysStringByteLen(VarPtr(strTest2)) 'result: 0
But this will not get me anywhere.
Possibly it works with an self-written dll to bypass cypress, but I would have to first learn VB.Net or C++.
Thanks
Robert
-
hello Robert,
can you pls describe, what you realy want to do.
for the Moment i am not able (maybe to old for this) to follow/get the real challenge.
-
Hi
I want outsourcing my non-sensibility IOs to a SPS and call them with Modbus.
But Modbus with API call, not Mach3 Modbus.
-
ok, i have no Experience about modbus,
maybe i can help a Little bit with VB Scripting.