如果条件许可可以容纳最大28000单字节字符串:Option Explicit Dim a As String Dim i As Integer Dim b As String Private Sub Command1_Click() a = "abcdefghijklmnopqrstuvwxyt" For i = 1 To 2000 b = b + a & vbCrLf Next i Label1.Caption = b Text1 = Len(Label1.Caption) End SubPrivate Sub VScroll1_Change() Label1.Top = VScroll1 * -100 End Sub
你将 Lable 控件设得越宽,就能显示越多的内容。
你将 Lable 控件设得越宽,就能显示越多的内容。 这不是好方法了
Dim s As Strings = "afjrgeognbdlhnlrt" Label1.Width = Me.TextWidth(s) Label1.Caption = s
Dim s As Strings = "afjrgeognbdlhnlrt" Label1.Width = Me.TextWidth(s) Label1.Caption = s 如果是这样,如果标鉴字符串超过窗体宽度,那超过的部分能显示出来吗
Option ExplicitConst strLongString As String = "abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgafgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgab结束了!" Dim p As IntegerPrivate Sub Form_Load() Label1.Left = 0 Label1.Caption = strLongString Debug.Print Len(strLongString) Timer1.Interval = 10 '这个值控制移动速度 Me.ScaleMode = 3 End Sub Private Sub Timer1_Timer() Label1.Left = Label1.Left - 1 If Label1.Left <= -(Len(Label1.Caption)) Then Label1.Left = Me.ScaleWidth End Sub
800*600分辨率下,28000字节长单字节字符: Option Explicit Dim a As String Dim i As Integer Dim b As String Private Sub Command1_Click() a = "AbcdefghijklmnopqrstuvwxyZ" For i = 1 To 2000 If i Mod 8 = 0 Then b = b + a & vbCrLf Else b = b + a End If Next i Label1.Caption = b Text1 = Len(Label1.Caption) End SubPrivate Sub Form_Load() Me.Height = 9000 Me.Width = 12000 Label1.Height = 30000 Label1.Width = 40000 End SubPrivate Sub HScroll1_Change() Label1.Left = HScroll1 * -10 End SubPrivate Sub VScroll1_Change() Label1.Top = VScroll1 * -10 End Sub
Dim s As String s = "afjrgeognbdlhnlrt" Label1.Width = Me.TextWidth(s) Label1.Caption = s 如果是这样,如果标鉴字符串超过窗体宽度,那超过的部分能显示出来吗 你问题中不是说移动显示吗?因为,移动显示了还是一样不能显示多于的部分了
如,label1.caption="sdfgsdfgsdfgsdfg"
2、标签显示文本框的内容:可达64k
Label1.Caption = Text1.Text
Debug.Print LenB(Label1.Caption)
Dim a As String
Dim i As Integer
Dim b As String
Private Sub Command1_Click()
a = "abcdefghijklmnopqrstuvwxyt"
For i = 1 To 2000
b = b + a & vbCrLf
Next i
Label1.Caption = b
Text1 = Len(Label1.Caption)
End SubPrivate Sub VScroll1_Change()
Label1.Top = VScroll1 * -100
End Sub
Dim s As Strings = "afjrgeognbdlhnlrt"
Label1.Width = Me.TextWidth(s)
Label1.Caption = s
Label1.Width = Me.TextWidth(s)
Label1.Caption = s
如果是这样,如果标鉴字符串超过窗体宽度,那超过的部分能显示出来吗
Dim p As IntegerPrivate Sub Form_Load()
Label1.Left = 0
Label1.Caption = strLongString
Debug.Print Len(strLongString)
Timer1.Interval = 10 '这个值控制移动速度
Me.ScaleMode = 3
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left - 1
If Label1.Left <= -(Len(Label1.Caption)) Then Label1.Left = Me.ScaleWidth
End Sub
Option Explicit
Dim a As String
Dim i As Integer
Dim b As String
Private Sub Command1_Click()
a = "AbcdefghijklmnopqrstuvwxyZ"
For i = 1 To 2000
If i Mod 8 = 0 Then
b = b + a & vbCrLf
Else
b = b + a
End If
Next i
Label1.Caption = b
Text1 = Len(Label1.Caption)
End SubPrivate Sub Form_Load()
Me.Height = 9000
Me.Width = 12000
Label1.Height = 30000
Label1.Width = 40000
End SubPrivate Sub HScroll1_Change()
Label1.Left = HScroll1 * -10
End SubPrivate Sub VScroll1_Change()
Label1.Top = VScroll1 * -10
End Sub
Label1.Width = Me.TextWidth(s)
Label1.Caption = s
如果是这样,如果标鉴字符串超过窗体宽度,那超过的部分能显示出来吗
你问题中不是说移动显示吗?因为,移动显示了还是一样不能显示多于的部分了
Dim i As Long
For i = 1 To 1000
Text1.Text = Text1.Text & i & "aaaaaaaaaabbbbbbbbbb"
Next i
Label1.BackStyle = 0 '透明标签
Label1.AutoSize = True
Label2.BackStyle = 0 '透明标签
Label2.AutoSize = True
' Picture1.ScaleMode = 3 '象素座标
' Me.ScaleMode = 3
Label2.Left = Label1.Left + Label1.Width
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
Static j As Long
Label1.Left = Label1.Left - 2000
Label2.Left = Label2.Left - 2000
If Label1.Left + Label1.Width < 0 Then
Label1.Left = Label2.Left + Label2.Width
If j + 200 >= Len(Text1.Text) Then
Label1.Caption = Mid(Text1.Text, j + 1, 200) & Left(Text1.Text, 200 - (Len(Text1.Text) - j))
j = 200 - (Len(Text1.Text) - j)
Else
Label1.Caption = Mid(Text1.Text, j + 1, 200)
j = j + 200
End If
End If
If Label2.Left + Label2.Width < 0 Then
Label2.Left = Label1.Left + Label1.Width
If j + 200 >= Len(Text1.Text) Then
Label2.Caption = Mid(Text1.Text, j + 1, 200) & Left(Text1.Text, 200 - (Len(Text1.Text) - j))
j = 200 - (Len(Text1.Text) - j)
Else
Label2.Caption = Mid(Text1.Text, j + 1, 200)
j = j + 200
End If
End If
End Sub
用于显示文本(输出)信息,不能作为输入信息的界面。
1.基本属性
Name、Height、Width、Top、Left、Enabled、Visible、Font、ForeColor、BackColor等与窗体的使用相同。
2.常用属性
(1)Caption属性
Caption属性用来改变Label控件中显示的文本。Caption属性允许文本的长度最多为1024字节。缺省情况下,当文本超过控件宽度时,文本会自动换行,而当文本超过控件高度时,超出部分将被裁剪掉。
(2)Alignment属性
设置Caption属性中文本的对齐方式,共有三种可选值:
0 左对齐(Left Justify);
1 右对齐(Right Justify);
2 居中对齐(Center Justify)。
(3)BackStyle属性
该属性用于确定标签的背景是否透明。有两种情况可选:值为0时,表示背景透明,标签后的背景和图形可见;值为1时,表示不透明,标签后的背景和图形不可见。
(4)AutoSize属性
AutoSize属性确定标签是否会随标题内容的多少自动变化。如果值为True,则随Caption内容的大小自动调整控件本身的大小,且不换行;如果值为False,表示标签的尺寸不能自动调整,超出尺寸范围的内容不予显示。
Dim i As Long
For i = 1 To 1000
Text1.Text = Text1.Text & i & "aaaaaaaaaabbbbbbbbbb"
Next i
Label1.BackStyle = 0 '透明标签
Label1.AutoSize = True
Label2.BackStyle = 0 '透明标签
Label2.AutoSize = True
' Picture1.ScaleMode = 3 '象素座标
' Me.ScaleMode = 3
Label1.Caption = Mid(Text1.Text, j + 1, 200)
j = j + 200
Label2.Caption = Mid(Text1.Text, j + 1, 200)
Label2.Left = Label1.Left + Label1.Width
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
Label1.Left = Label1.Left - 2000
Label2.Left = Label2.Left - 2000
If Label1.Left + Label1.Width < 0 Then
Label1.Left = Label2.Left + Label2.Width
If j + 200 >= Len(Text1.Text) Then
Label1.Caption = Mid(Text1.Text, j + 1, 200) & Left(Text1.Text, 200 - (Len(Text1.Text) - j))
j = 200 - (Len(Text1.Text) - j)
Else
Label1.Caption = Mid(Text1.Text, j + 1, 200)
j = j + 200
End If
End If
If Label2.Left + Label2.Width < 0 Then
Label2.Left = Label1.Left + Label1.Width
If j + 200 >= Len(Text1.Text) Then
Label2.Caption = Mid(Text1.Text, j + 1, 200) & Left(Text1.Text, 200 - (Len(Text1.Text) - j))
j = 200 - (Len(Text1.Text) - j)
Else
Label2.Caption = Mid(Text1.Text, j + 1, 200)
j = j + 200
End If
End If
End Sub