📄 module1.bas
字号:
Attribute VB_Name = "Module1"
'Practicum 2
Public Cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rs1 As New ADODB.Recordset
Public rs2 As New ADODB.Recordset
Public rstemp As New ADODB.Recordset
Public lst As ListItem
Public Sub connect()
Dim path As String
On Error GoTo ado2
path = App.path & "\database.mdb" & ";Jet " & "OLEDB:Database Password=hotel"
Cnn.CursorLocation = adUseClient
If rs.State = 1 Then rs.Close
Cnn.Open "provider=MSDASQL.1;Persist Security Info=False;Data Source=invent"
Exit Sub
ado2:
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & path
End Sub
Public Sub check_RStemp()
If rstemp.State = 1 Then rstemp.Close
End Sub
Public Sub check_RS()
If rs.State = 1 Then rs.Close
End Sub
Public Sub check_RS1()
If rs1.State = 1 Then rs1.Close
End Sub
Public Sub check_RS2()
If rs2.State = 1 Then rs2.Close
End Sub
Sub Explode(frm As Form)
Dim x As Long
Dim factor As Double
Dim width As Integer
Dim height As Integer
height = frm.height
width = frm.width
factor = height / width
frm.width = 0
frm.height = 0
frm.Show
For x = 0 To width Step 215
frm.width = x
frm.height = x * factor
With frm
.Left = (Screen.width - .width) / 2
.Top = (Screen.height - .height) / 2
End With
Next x
End Sub
Sub autonogeneration()
check_RS
rs.Open "select * from function_room", Cnn
Dim automan As String
On Error Resume Next
rs.MoveLast
automan = rs.Fields(0)
automan = Val(Mid(automan, 2, Len(automan)))
If automan < 10 Then
automan = "F0000" & (CInt(automan) + 1)
GoTo out
ElseIf automan < 100 Then
automan = "F000" & (CInt(automan) + 1)
GoTo out
ElseIf automan < 1000 Then
automan = "F00" & (CInt(automan) + 1)
GoTo out
ElseIf automan < 10000 Then
automan = "F0" & (CInt(automan) + 1)
GoTo out
ElseIf automan < 100000 Then
automan = "F" & (CInt(automan) + 1)
GoTo out
End If
out:
frmFuncRoomData.data(0).Text = automan
End Sub
Public Function ConvertToMonth(x As Integer) As String
Dim themonth As String
Select Case x
Case 1: themonth = "January"
Case 2: themonth = "February"
Case 3: themonth = "March"
Case 4: themonth = "April"
Case 5: themonth = "May"
Case 6: themonth = "June"
Case 7: themonth = "July"
Case 8: themonth = "August"
Case 9: themonth = "September"
Case 10: themonth = "October"
Case 11: themonth = "November"
Case 12: themonth = "December"
End Select
ConvertToMonth = themonth
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -