中查找“一个Format函数”更多相关内容
中查找“一个Format函数”更多相关内容
- ·上一篇文章:用API打开打印对话框
- ·下一篇文章:延时函数
一个Format函数
一个Format函数
A new Format function
Visual Basic 5 has the Format command that almost works the same as Print. The difference is that Format shortens the output string length if all the format characters are not used. To work around this I wrote a Public Function called FormatNum.
Public Function FormatNum(MyNumber As Double, FormatStr As String) As String
注释: This Function returns number formatted as a string
注释: with the desired minimum number of characters
注释: MyNumber - Use CDbl(MyNumber) in the function
注释: call to prevent type mismatch error.
注释:
FormatNum = Format$(MyNumber, FormatStr)
If Len(FormatNum) < Len(FormatStr) Then
FormatNum = Space$(Len(FormatStr) - Len(FormatNum)) & FormatNum
End If
End Function
Use this function like this:
Print #FileNumber, FormatNum(CDbl(MyVariable), " #### ")