03-30-2024, 04:17 AM
(This post was last modified: 03-30-2024, 04:20 AM by TerryRitchie.)
(03-30-2024, 03:29 AM)eoredson Wrote: An interesting code snippet to get a string variable from print using:Hmmm, that's interesting. In other words what you are looking for would be something like this:
Although I cannot find a more efficient way to do this..Code: (Select All)'sample assigning formatted string from print using to a variable:
Rem x$ = Print Using "###"; 100
X = FreeFile
F$ = "tempfile.bak"
Print "Enter value";
Input Z#: If Z# = 0# Then Z# = 100#
Print "Enter format";
Input Z$: If Z$ = "" Then Z$ = "###"
'write print using value
Open F$ For Output As #X
Print #X, Using Z$; Z#
'read print using value
Close
Open F$ For Input As #X
If EOF(X) = 0 Then
Line Input #X, S$
Print S$ ' this is the output value
End If
Close
End
Erik.
Num = 100
use$ = "This is a test -> ###"
s$ = USING use$, Num
s$ would then contain: This is a test -> 100
I've always used USING to format output to a printer or file but I never gave any thought to USING being utilized in this manner. It's an interesting concept though. The only way I see to do this (besides the method you showed above) would be to create functions and/or subs to preformat strings for you.