Results 1 to 5 of 5

Thread: string problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Québec City
    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

  2. #2
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    South Africa


    Your code worked perfectly when I tried it??!!?? Try declaring test as a variant.

  3. #3
    Fanatic Member
    Join Date
    Nov 2000
    Worldwide in the Sun

    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 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)


  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Québec City
    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


    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
    but, since this in an array, I can see all the characters with a loop like:

    After that I called it once, I want to call it once again but this time with
    longueur=use '42 in our example

    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?

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    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.
    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

Click Here to Expand Forum to Full Width