Click to See Complete Forum and Search --> : VB equivalent for sprintf


MarionMcD
July 19th, 2001, 03:30 AM
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

cksiow
July 19th, 2001, 03:49 AM
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

MarionMcD
July 19th, 2001, 03:52 AM
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?