|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 marmot777 于 2024-7-28 11:28 编辑
导入系统时间t,当t=A1时显示B1内容,当t=A2时显示B2内容,......,以此类推。代码如下:
Sub 显示成交()
Dim t As Date
Dim txtBox As Shape
Do
t = Time ' 获取时间
' 添加文本框
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
For i = 1 To Range("A1").End(xlDown).Row
If Range("a" & i) = t Then txtBox.TextFrame2.TextRange.Text = Range("b" & i)
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
DoEvents
Loop
End Sub
运行程序,经常有t=An时,文本框不显示Bn内容,这是什么原因?
|
|