?? frmadtext.frm
字號:
VERSION 5.00
Begin VB.Form frmADText
Caption = "滾動廣告條內容設置"
ClientHeight = 3780
ClientLeft = 60
ClientTop = 345
ClientWidth = 5235
BeginProperty Font
Name = "宋體"
Size = 9.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 3780
ScaleWidth = 5235
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton CmdDel
Caption = "刪除"
Height = 375
Left = 1680
TabIndex = 4
Top = 3240
Width = 1335
End
Begin VB.CommandButton CmdADD
Caption = "添加"
Height = 375
Left = 240
TabIndex = 3
Top = 3240
Width = 1335
End
Begin VB.ListBox List1
Height = 2205
Left = 120
TabIndex = 2
Top = 120
Width = 4935
End
Begin VB.TextBox Text2
Height = 375
Left = 120
TabIndex = 1
Top = 2520
Width = 4815
End
Begin VB.CommandButton CmdSave
Caption = "保存"
Height = 375
Left = 3120
TabIndex = 0
Top = 3240
Width = 1335
End
End
Attribute VB_Name = "frmADText"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private iniPath As String
Private Entry As String
Private Sub CmdADD_Click()
Debug.Print "text2 ", LenB(StrConv(Text2.Text, vbFromUnicode))
'添加廣告詞
Text2.Locked = False
List1.AddItem Text2.Text
End Sub
Private Sub CmdDel_Click()
'刪除廣告詞,注意:在這里會刪除所有的廣告詞,有興趣的話可以把它改為刪除當前廣告詞
Debug.Print List1.ListIndex
List1.Clear
End Sub
Private Sub CmdSave_Click()
Dim strAD As String
Dim i, r As Long
'計算廣告詞總數
Entry$ = Str(List1.ListCount)
r = WritePrivateProfileString("滾動廣告條", "數量", Entry, iniPath)
For i = 0 To List1.ListCount
Debug.Print Entry
Entry$ = List1.List(i)
strAD = "廣告詞" + Str(i)
'把廣告詞保存在INI文件中。strAD是標題 Entry是內容 iniPath是INI文件路徑
r = WritePrivateProfileString("滾動廣告條", strAD, Entry, iniPath)
Next i
End Sub
Private Sub Form_Load()
Dim i, ADcount As Long
'設定廣告詞配置文件路徑
iniPath$ = App.Path + "\SysSet.ini"
'讀取廣告詞總數
ADcount = Val(GetFromINI("滾動廣告條", "數量", iniPath))
Debug.Print ADcount
'循環讀出所有廣告詞
If ADcount > 1 Then
For i = 0 To ADcount - 1
List1.AddItem GetFromINI("滾動廣告條", "廣告詞" + Str(i), iniPath)
Next i
End If
End Sub
Private Sub Text2_Change()
'由于滾動廣告條的設計原理是把寫有廣告詞的label控件放在Picture控件上,然后移動Picture。這種方法決定了廣告詞的長度不能超出Picture控件的長度。
'為了防止這種事情的發生,在輸入廣告詞時就要進行檢查!
If LenB(StrConv(Text2.Text, vbFromUnicode)) >= 36 Then
MsgBox "廣告詞過長,將無法在滾動條內完全顯示。建議您把長句分段!", vbInformation, "警告"
Text2.Locked = True
End If
Debug.Print LenB(StrConv(Text2.Text, vbFromUnicode))
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -