|
-
Nov 11th, 2000, 12:27 AM
#1
Thread Starter
Lively Member
I have a little problem with strings
if I do:
---
test = "test" & Chr(0) & Chr(0) & Chr(0) & "test"
Label1.Caption = Right(test, 1)
---
then the caption of the label will stay blank while it is supposed to be "t".
It seems that the second "test" is lost...
Is there a way to get ALL the characters in the string so they can be put in label1.caption?
Thank you
-
Nov 11th, 2000, 03:19 AM
#2
Hyperactive Member
Umm?
Your code worked perfectly when I tried it??!!?? Try declaring test as a variant.
-
Nov 11th, 2000, 04:20 AM
#3
Fanatic Member
Re: Umm?
<???>
The code is correct and worked fine.
Where did you put your code.
I've created a form with a label and a commandbutton
In the command1.click I put your code.
No problems
You are running the program I hope, and did not click
in the form by creation, because than it gives no results. (joking but it happens)
Cheers
Ray
-
Nov 11th, 2000, 09:40 AM
#4
Thread Starter
Lively Member
haha, you're right
Maybe I was a little bit tired...
but that wasn't the original problem... I was trying to find an anwser to it by this way.
Here is the real problem:
I'm using a dll that uses for example the function "UseDll"
I have this declaration in a module
Public Declare Function UseDll Lib "MyLib.dll" (ByRef test As String, ByVal longueur As Integer, ByVal Usage As Integer) As Integer
This is a real C dll, not an active X.
So, if I use it with:
dim test as string
dim Usage as integer
dim longueur as integer
dim use as integer
test="This is a test that I'm doing"
Usage = 1
longueur=0 'this is not important when Usage is 1
use=UseDll(test,longueur,Usage)
then, the string "test" will be modified, and the lenght of this string will be "use"
The problem is, when I execute this, use=42 BUT in vb I get that len(test)=15, so, if label1.caption=test I will only see the first 15 characters of "test"
I think there is a character in the string that tells vb that the end of the string is charater 15...
Just by the way, I would get the same problem in C with
printf("%s",test);
but, since this in an array, I can see all the characters with a loop like:
for(i=0;i<use;i++)
printf("%c",test[i];
After that I called it once, I want to call it once again but this time with
Usage=2
longueur=use '42 in our example
use=UseDll(test,longueur,Usage)
but I don't want to call it immediately after the first call, so I must have the first string "test" (array of "use" characters) stored properly on my hard drive.
Finally, I must find a way to get all the 42 characters, not only 15...
Any idea or suggestion?
-
Nov 11th, 2000, 10:11 AM
#5
transcendental analytic
Well i'm not really sure what kind of problem this is you have, but one thing is for sure. IF you put a string containing nullchars(chr(0)) into a textbox or label, it will cut of the rest of the string. On the other hand if you put it in a richtextbox it wont do it.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|