none
declaring and using VB Strings of different fixed sizes. e.g.: using 'dim afixedlengthstring as string as 12' within VB. RRS feed

  • Question

  •  I do remember programming in vb6, where I could make many different fixed length VB strings, without running into this error called: "End of Statement expected".    Saying that I have used vb6 before dates me, of which is true.  I have used vb6 and enjoyed it.

    By using this "old" vb template(Dim fixedstring1 as string as 12), I could make many different fixed length strings quite easily, whether in a structure or independently.

    With using the MSVC 2010 VB environment, I'm always running into the error: "End of Statement expected" when/where I'm using this "old"  vb template(Dim fixedstring1 as string as 12).  I do have access to a full MSVC 2017 environment. Would using this 2017 vb environment be much better, and get rid of this error of "End of Statement expected"??

    Yet, I could change this '12' to be a different number; thus creating many other different fixed length strings.  Currently, I have developed a "C"/C++ program/DLL that uses fixed strings of 12 characters as vehicles. These "vehicles" contains data that is passed to many other "C"/C++ routines to do certain process' and also these "vehicles" are also passed, carrying data from this/my vb program(if I can get my vb program working and running) to my "C"/C++ routines and back.

    Therefore, I respectfully ask for some help in getting over these problemsome hurtles. And is there someone who could help me get thru it. If someone wants to know what my project is, just ask and I'll tell.  Many thanks in advance.

    Thad T.

    Nov 24th, 2019

    RSVP Please...

    Sunday, November 24, 2019 5:12 AM

All replies

  • You probably mean ‘Dim fixedstring1 As String * 12’.

    Maybe you can use normal strings instead of such obsolete definitions. When you need a truncated and padded string, you can use LSet:

       Dim string1 As String

       string1 = "text"

     

       Dim fixedstring1 As String

       fixedstring1 = LSet(string1, 12) ' it is "text________"

     

    See also: https://www.bing.com/search?q=VB.NET+fixed+width+strings. For interaction with C++, probably you can use the <VBFixedString(12)> attribute for members.

    • Edited by Viorel_MVP Sunday, November 24, 2019 8:49 AM
    Sunday, November 24, 2019 8:43 AM
  • A little bit in addition to Viorel's message about obsolete.

    Fixed strings, are your programs still based on non proportional fonts? Because that is AFAIK the only reason to use those fixed strings. (Or you've to deal with an other organisation who still want to get information delivered in a punch card style format)

    Not obsolete, but real time to think about that. 

    From the time of this kind of printers. 

    https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/IBM_1403_Printer_opened.jpg/220px-IBM_1403_Printer_opened.jpg

    However, maybe you've an other reason. 


    Success
    Cor


    Sunday, November 24, 2019 11:28 AM