?? generalfunc.bas
字號(hào):
Attribute VB_Name = "GeneralFunc"
Public Sub Add_ClassToTree(TreeView1 As TreeView, _
ByVal TmpKey As String)
Dim Bh As Long
Dim TmpNode As Node
'當(dāng)前選擇結(jié)點(diǎn)的關(guān)鍵字
Dim CurKey As String
'臨時(shí)數(shù)組
Dim TmpArr_ClassName() As String
Dim TmpArr_ClassId() As Long
ReDim TmpArr_ClassName(0)
ReDim TmpArr_ClassId(0)
'從關(guān)鍵字中讀取當(dāng)前的院系班級(jí)編號(hào)
Bh = Val(Right(TmpKey, Len(TmpKey) - 1))
'獲取當(dāng)前院系班級(jí)信息
MyClass.GetInfo (Bh)
'讀取當(dāng)前院系班級(jí)的下一級(jí)院系班級(jí)數(shù)據(jù)
MyClass.Load_Class_ByUpper (Bh)
'將下一級(jí)院系班級(jí)數(shù)據(jù)賦值到臨時(shí)數(shù)組中
i = 0
Do While Arr_ClassName(i) <> ""
ReDim Preserve TmpArr_ClassName(i + 1)
TmpArr_ClassName(i) = Arr_ClassName(i)
ReDim Preserve TmpArr_ClassId(i + 1)
TmpArr_ClassId(i) = Arr_ClassId(i)
i = i + 1
Loop
i = 0
Do While TmpArr_ClassName(i) <> ""
'生成院系班級(jí)對(duì)應(yīng)的關(guān)鍵字,格式為“字母a”+院系班級(jí)編號(hào)
CurKey = "a" + Trim(Str(TmpArr_ClassId(i)))
'如果當(dāng)前院系班級(jí)有下一級(jí)院系班級(jí),則顯示文件夾圖標(biāo)
If MyClass.HaveSon(TmpArr_ClassId(i)) = True Then
Set TmpNode = TreeView1.Nodes.Add(TmpKey, _
tvwChild, CurKey, TmpArr_ClassName(i), 1, 3)
TmpNode.ExpandedImage = 2
'否則顯示葉結(jié)點(diǎn)圖標(biāo)
Else
Set TmpNode = TreeView1.Nodes.Add(TmpKey, _
tvwChild, CurKey, TmpArr_ClassName(i), 4, 5)
End If
'FocusClassName、FocusClassBh和FocusClassKey分別表示希望選中的院系班級(jí)的名稱、編號(hào)和關(guān)鍵字
If FocusClassName <> "" And TmpArr_ClassName(i) = FocusClassName Then
TmpNode.Selected = True
FocusClassKey = CurKey
End If
If FocusClassBh > 0 And TmpArr_ClassId(i) = FocusClassBh Then
TmpNode.Selected = True
FocusClassKey = CurKey
End If
If FocusClassKey <> "" And CurKey = FocusClassKey Then
TmpNode.Selected = True
End If
'以當(dāng)前院系班級(jí)為參數(shù)遞歸調(diào)用
Call Add_ClassToTree(TreeView1, CurKey)
i = i + 1
Loop
End Sub
Public Function In_Single(KeyAscii As Integer) As Boolean
Dim Ch_Accept_Single(20) As String
'可以接受的字符數(shù)組
Ch_Accept_Single(0) = "0"
Ch_Accept_Single(1) = "1"
Ch_Accept_Single(2) = "2"
Ch_Accept_Single(3) = "3"
Ch_Accept_Single(4) = "4"
Ch_Accept_Single(5) = "5"
Ch_Accept_Single(6) = "6"
Ch_Accept_Single(7) = "7"
Ch_Accept_Single(8) = "8"
Ch_Accept_Single(9) = "9"
Ch_Accept_Single(10) = "."
Ch_Accept_Single(11) = "-"
Ch_Accept_Single(12) = Chr(8)
'檢查輸入字符是否在數(shù)組中
In_Single = False
For i = 0 To 12
If Chr(KeyAscii) = Ch_Accept_Single(i) Then
In_Single = True
End If
Next
End Function
Public Function In_Int(KeyAscii As Integer) As Boolean
Dim Ch_Accept_Int(20) As String
'可以接受的字符數(shù)組
Ch_Accept_Int(0) = "0"
Ch_Accept_Int(1) = "1"
Ch_Accept_Int(2) = "2"
Ch_Accept_Int(3) = "3"
Ch_Accept_Int(4) = "4"
Ch_Accept_Int(5) = "5"
Ch_Accept_Int(6) = "6"
Ch_Accept_Int(7) = "7"
Ch_Accept_Int(8) = "8"
Ch_Accept_Int(9) = "9"
Ch_Accept_Int(10) = Chr(8)
'檢查輸入字符是否在數(shù)組中
In_Int = False
For i = 0 To 10
If Chr(KeyAscii) = Ch_Accept_Int(i) Then
In_Int = True
End If
Next
End Function
Public Function InCombo(ByVal Str As String, _
ByVal Combo1 As ComboBox) As Boolean
i = 0
Do While i < Combo1.ListCount
If Combo1.List(i) = Trim(Str) Then
InCombo = True
Exit Function
End If
i = i + 1
MsgBox Str + " 不在列表中,請(qǐng)重新設(shè)置"
InCombo = False
End Function
Public Function Lench(ByVal TmpStr As String) As String
Lench = LenB(StrConv(TmpStr, vbFromUnicode))
End Function
Public Function TrimStr(ByVal Str As String) As String
If InStr(Str, Chr(0)) <= 0 Then
TrimStr = Trim(Str)
Else
TrimStr = Trim(Left(Str, InStr(Str, Chr(0)) - 1))
End If
End Function
Public Function MakeStr(ByVal Str As String) As String
MakeStr = Trim(Replace(Str, "'", "''"))
End Function
Public Sub EnterTAB(KeyAscii As Integer)
If KeyAscii = 13 Then '13表示回車鍵
SendKeys "{TAB}" '轉(zhuǎn)換為TAB鍵
End If
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -