IMcOMGlobalMcSprintf Method |
![]() |
Namespace: MediaCy.IQL.ObjectManager
Function McSprintf ( FormatString As String, <OutAttribute> ParamArray ByRef VariableNumberOfArguments As Object() ) As String
Debug.Print McSprintf(McCStr("\nThis is a test with one string arg. %s"), "Hello world") & vbCrLf & _ " Above was McSprintf(McCStr(""This is a test with one string arg. %s""), ""Hello world"")" Debug.Print McSprintf(McCStr("\nTest of mixed scalar args: Byte(%d), Short(%d), Long(%d), Float(%f), Double(%f)"), _ CByte(10), CInt(10), CLng(10), CSng(10), CDbl(10)) & vbCrLf & _ " Above was McSprintf(McCStr(""Test of mixed scalar args: Byte(%d), Short(%d), Long(%d), Float(%f), Double(%f)""), CByte(10), CInt(10), CLng(10), CSng(10), CDbl(10))" Debug.Print McSprintf(McCStr("\nThe %s %c is Chr(%d), %s"), "letter", 65, 65, "right?") & vbCrLf & _ " Above was McSprintf(McCStr(""\nThe %s %c is Chr(%d), %s""), ""letter"", 65, 65, ""right?"")" Debug.Print McSprintf(McCStr("\nThis is a string with no arguments.")) & vbCrLf & _ " Above was McSprintf(McCStr(""\nThis is a string with no arguments.""))" Dim myPt As LONGPOINT myPt.x = 10 myPt.y = 20 Debug.Print McSprintf(McCStr("\nHere is a LONGPOINT: x=%d, y=%d."), myPt) & vbCrLf & _ " Above was McSprintf(McCStr(""\nHere is a LONGPOINT: x=%d, y=%d.""), myPt)" Dim mcobjString As McObject Set mcobjString = McObjectTemp("string in an McObject") Debug.Print McSprintf(McCStr("\nCan we show a %s?"), mcobjString) & vbCrLf & _ " Above was McSprintf(McCStr(""\nCan we show a %s?""), mcobjString)" Dim strArray(0 To 2) As String strArray(0) = "Line 0." strArray(1) = "Line 1." strArray(2) = "Line 2." Debug.Print McSprintf(McCStr("\nAn array of strings.\n1. %s\n2. %s\n3. %s"), strArray) & vbCrLf & _ " Above was McSprintf(McCStr(""\nAn array of strings.\n1. %s\n2. %s\n3. %s""), strArray)" 'Convert the above array of strings above to an McObject, and then sprintf that Dim mcobjStrArray As McObject Set mcobjStrArray = McObjectTemp(strArray) Debug.Print McSprintf(McCStr("\nAn array of strings in an McObject\n1. %s\n2. %s\n3. %s"), mcobjStrArray) & vbCrLf & _ " Above was McSprintf(McCStr(""\n\nAn array of strings in an McObject\n1. %s\n2. %s\n3. %s""), mcobjStrArray)" '**** The output produced by the above tests is shown below **** ' ' This is a test with one string arg. Hello world ' Above was McSprintf(McCStr("This is a test with one string arg. %s"), "Hello world") ' ' Test of mixed scalar args: Byte(10), Short(10), Long(10), Float(10.000000), Double(10.000000) ' Above was McSprintf(McCStr("Test of mixed scalar args: Byte(%d), Short(%d), Long(%d), Float(%f), Double(%f)"), CByte(10), CInt(10), CLng(10), CSng(10), CDbl(10)) ' ' The letter A is Chr(65), right? ' Above was McSprintf(McCStr("\nThe %s %c is Chr(%d), %s"), "letter", 65, 65, "right?") ' ' This is a string with no arguments. ' Above was McSprintf(McCStr("\nThis is a string with no arguments.")) ' ' Here is a LONGPOINT: x=10, y=20. ' Above was McSprintf(McCStr("\nHere is a LONGPOINT: x=%d, y=%d."), myPt) ' ' Can we show a string in an McObject? ' Above was McSprintf(McCStr("\nCan we show a %s?"), mcobjString) ' ' An array of strings. ' 1. Line 0. ' 2. Line 1. ' 3. Line 2. ' Above was McSprintf(McCStr("\nAn array of strings.\n1. %s\n2. %s\n3. %s"), strArray) ' ' An array of strings in an McObject ' 1. Line 0. ' 2. Line 1. ' 3. Line 2. ' Above was McSprintf(McCStr("\n\nAn array of strings in an McObject\n1. %s\n2. %s\n3. %s"), mcobjStrArray)