|
楼主 |
发表于 2024-8-5 21:49
|
显示全部楼层
我把加载文本框写在循环外边,只加载一次,然后测试,还是出问题。那我只有把时间也设置成每秒加载一次。代码如下:
Sub 显示成交()
Dim t As Date
Dim txtBox As Shape
Dim txtbox1 As Shape
' 添加文本框
Set txtBox = ActiveSheet.Shapes.AddTextbox( _
msoTextOrientationHorizontal, _
Left:=1, Top:=1, Width:=370, Height:=170)
' 设置文本框的字体大小
txtBox.TextFrame2.TextRange.Font.Size = 48
' 设置文本框背景颜色
txtBox.Fill.ForeColor.RGB = RGB(255, 255, 160)
txtBox.Fill.Visible = msoTrue
' 设置文本框字体加粗
txtBox.TextFrame2.TextRange.Font.Bold = msoTrue
' 添加文本框1
Set txtbox1 = ActiveSheet.Shapes.AddTextbox( _
msoTextOrientationHorizontal, _
Left:=1, Top:=170, Width:=370, Height:=70)
' 设置文本框1的字体大小
txtbox1.TextFrame2.TextRange.Font.Size = 48
' 设置文本框1背景颜色
txtbox1.Fill.ForeColor.RGB = RGB(255, 255, 160)
txtbox1.Fill.Visible = msoTrue
' 设置文本框1字体加粗
txtbox1.TextFrame2.TextRange.Font.Bold = msoTrue
t = Time
For i = 1 To Range("A1").End(xlDown).Row
If Range("a" & i).Text = Format(t, "hh:mm:ss") Then txtBox.TextFrame2.TextRange.Text = Range("b" & i)
If Range("a" & i).Text = Format(t, "hh:mm:ss") Then txtbox1.TextFrame2.TextRange.Text = Range("c" & i)
If Range("a" & i).Text = Format(t, "hh:mm:ss") Then Beep
g = txtBox.TextFrame2.TextRange.Text
For c = 1 To Len(g)
If Mid(g, c, 1) = "成" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = "交" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = "(" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = ")" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = "挂" Then txtBox.TextFrame.Characters(c, 1).Font.Color = vbBlue
If Mid(g, c, 1) = "撤" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(128, 0, 255)
Next
Next
Application.OnTime t + 1 / 24 / 3600, "显示成交"
End Sub
你看这样写行不?
|
|