如何设置print方法的align参数?我想print出来的文字右对齐

at20001 2004-11-13 11:36:27
如题
...全文
211 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
leolan 2004-11-13
  • 打赏
  • 举报
回复
Private Sub Form_Load()
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
NewPeople 2004-11-13
  • 打赏
  • 举报
回复
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 Long

Declare Function SetTextAlign Lib "gdi32" Alias "SetTextAlign" (ByVal hdc As Long, ByVal wFlags As Long) As Long

保你没问题
at20001 2004-11-13
  • 打赏
  • 举报
回复
我想应该可以向窗体发送一个消息,设置文本对齐方式.但是不知道是那个消息.
wwqna 2004-11-13
  • 打赏
  • 举报
回复
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
tztz520 2004-11-13
  • 打赏
  • 举报
回复
Private Sub Form_Load()
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
at20001 2004-11-13
  • 打赏
  • 举报
回复
字符宽度不一样,这样还是对不齐

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧