Hello Guest it is November 22, 2019, 12:06:10 AM

Author Topic: VB - vbNullChar pass to function  (Read 819 times)

0 Members and 1 Guest are viewing this topic.

VB - vbNullChar pass to function
« 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.

Code: [Select]
'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

Offline TPS

*
  •  1,407 1,407
    • View Profile
Re: VB - vbNullChar pass to function
« Reply #1 on: November 19, 2018, 03:16:29 AM »
Looks like cypress can not handle the CHR(0)

if you try

strTest = &H00
len(strTest) gives the result 1
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: VB - vbNullChar pass to function
« Reply #2 on: November 19, 2018, 09:06:02 AM »
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

Offline TPS

*
  •  1,407 1,407
    • View Profile
Re: VB - vbNullChar pass to function
« Reply #3 on: November 20, 2018, 02:22:48 AM »
Hi Robert,

did two test's, see screenshots.
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  1,407 1,407
    • View Profile
Re: VB - vbNullChar pass to function
« Reply #4 on: November 20, 2018, 02:25:13 AM »
and a third one, seems to be ok.
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: VB - vbNullChar pass to function
« Reply #5 on: November 20, 2018, 10:10:49 AM »
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:
Code: [Select]
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

Offline TPS

*
  •  1,407 1,407
    • View Profile
Re: VB - vbNullChar pass to function
« Reply #6 on: November 20, 2018, 02:23:59 PM »
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.
« Last Edit: November 20, 2018, 02:38:05 PM by TPS »
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: VB - vbNullChar pass to function
« Reply #7 on: November 20, 2018, 06:05:25 PM »
Hi

I want outsourcing my non-sensibility IOs to a SPS and call them with Modbus.
But Modbus with API call, not Mach3 Modbus.

Offline TPS

*
  •  1,407 1,407
    • View Profile
Re: VB - vbNullChar pass to function
« Reply #8 on: November 21, 2018, 03:58:36 AM »
ok, i have no Experience about modbus,
maybe i can help a Little bit with VB Scripting.
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.