CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2001
    Posts
    7

    VB equivalent for sprintf

    Hi there,

    I'm looking for a VB method of using placeholders in a string so that dynamic text can be substituted in. For example, in C++, one could do:

    char* buffer;

    sprintf( buffer, "The quick brown %s jumped over the lazy dog.", "fox");



    And then the buffer would contain "The quick brown fox jumped over the lazy dog."

    Basically, I want to load text from a data file, which contains some sort of placeholder like this, so that I can easily insert any dynamic text into the string without having to fiddle about with Split or ReplaceWord or things like that if I can help it.

    Thanks!
    Marion


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: VB equivalent for sprintf

    in vb, it's much simpler.

    buffer = The quick brown " & cstr(fox) & jumped over the lazy dog."

    where fox is the string variable.

    Format statement is helpful too.



    HTH

    cksiow
    http://vblib.virtualave.net - share our codes

  3. #3
    Join Date
    Jul 2001
    Posts
    7

    Re: VB equivalent for sprintf

    The trouble is, I want to load a single string from a file and insert the dynamic text into various bits of it. I don't want three or four small strings that I'll have to & together like that.

    Is there any other way?



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

Featured