Const LeftMargin As Integer = 1000 Private Sub Form_Load() Dim maxwidth As Single Me.AutoRedraw = True maxwidth = Me.TextWidth("中国") Me.CurrentX = LeftMargin + maxwidth - Me.TextWidth("a") Print "a" Me.CurrentX = LeftMargin + maxwidth - Me.TextWidth("中国") Print "中国" End Sub
Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As LongDeclare Function SetTextAlign Lib "gdi32" Alias "SetTextAlign" (ByVal hdc As Long, ByVal wFlags As Long) As Long保你没问题
Me.AutoRedraw = True
Print Spc(10 - Len("a")); "a"
Print Spc(10 - Len("ab")); "ab"
Print Spc(10 - Len("abc")); "abc"
Print Spc(10 - Len("abcd")); "abcd"
End Sub
Me.Font = "Courier" '使用固定间距的字体
Me.AutoRedraw = True
Print Spc(10 - Len("a")); "a"
Print Spc(10 - Len("ab")); "ab"
Print Spc(10 - Len("abc")); "abc"
Print Spc(10 - Len("abcd")); "abcd"
End SubSub
Private Sub Form_Load()
Dim maxwidth As Single
Me.AutoRedraw = True
maxwidth = Me.TextWidth("中国")
Me.CurrentX = LeftMargin + maxwidth - Me.TextWidth("a")
Print "a"
Me.CurrentX = LeftMargin + maxwidth - Me.TextWidth("中国")
Print "中国"
End Sub