用户登录  |  用户注册
首 页 ┆ 商业源码 ┆ 原创产品 ┆ 编程论坛
当前位置:PB创新网 → 文章中心 → 编程技巧 → VisualBasic

一个Format函数

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 19:51:03

一个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), " #### ")

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网【ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:12,828.13000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号