⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formwiz.frm

📁 关于VB模块的
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    Screen.MousePointer = vbHourglass
    
    'Open an updateable record set
    ' using the exisiting Database object db
    Set rs = db.OpenRecordset _
        ("Select Dep_ID, Dep_name From department", dbOpenDynaset)
 
    ' Update all of the rows in the department table
    Do Until rs.EOF
        rs.Edit
        ' Jet returns blank filled strings -- truncate at the first blank
        sTemp = RTrim(rs!Dep_Name)
        rs!Dep_Name = "Updated " & sTemp
        rs.Update
        rs.MoveNext
    Loop
    
    ' Display the updated records
    DisplayDynasetGrid rs, Grid, 1
    
    rs.Close
    
    Screen.MousePointer = vbDefault
    
End Sub

Private Sub DeleteUsingRecordset()
    
    Dim rs As Recordset
    Dim i As Integer
    
    Screen.MousePointer = vbHourglass
    
    'Open an updateable recordset using an existing Database object
    Set rs = db.OpenRecordset("Select * From department", dbOpenDynaset)
    
    ' Delete all of the rows in the department table
    Do Until rs.EOF
        rs.Delete
        rs.MoveNext
    Loop
    
    ' Display the empty records
    DisplayDynasetGrid rs, Grid, 1
        
    rs.Close
    
    Screen.MousePointer = vbDefault

End Sub
Private Sub AddUsingInsert()

    Dim i As Integer
    Dim sSQL As String
    On Error GoTo Errorhandler
    
    Screen.MousePointer = vbHourglass
    
    ' No recordset is needed
    For i = 1 To 50
        sSQL = "Insert Into department " & _
            "Values('" & CStr(i) & "','DEPARTMENT " & CStr(i) & "')"
        db.Execute sSQL, dbSQLPassThrough
        sSQL = vbNullString
    Next
    
    Screen.MousePointer = vbDefault
    Exit Sub
    
Errorhandler:
    DisplayDAOError
    
    Screen.MousePointer = vbDefault

End Sub
Private Sub UpdateUsingUpdate()

    Dim sSQL As String
    On Error GoTo Errorhandler
            
    Screen.MousePointer = vbHourglass
    
    sSQL = "Update department " & _
        "Set Dep_Name = 'UPDATE' + Substring(Dep_Name, 7, 25)"
    
    db.Execute sSQL, dbSQLPassThrough
    
    Screen.MousePointer = vbDefault
    Exit Sub
    
Errorhandler:
    DisplayDAOError

    Screen.MousePointer = vbDefault


End Sub
Private Sub DeleteUsingDelete()

    Dim sSQL As String
    On Error GoTo Errorhandler
       
    Screen.MousePointer = vbHourglass
    
    sSQL = "Delete department"
    db.Execute sSQL, dbSQLPassThrough
    
    Screen.MousePointer = vbDefault
    Exit Sub
   
Errorhandler:
    DisplayDAOError
    
   Screen.MousePointer = vbDefault

End Sub
Private Sub ShowError()
    
    Dim rs As Recordset
    Dim sSQL As String
    On Error GoTo Errorhandler
    
    sSQL = "Select * From no_such_table"
    Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)
    rs.Close
    
    Exit Sub
    
Errorhandler:
    DisplayDAOError

End Sub
Private Sub Finish()
'    Timer1.Enabled = False
'    Set Image1.Picture = LoadResPicture(106, vbResBitmap)
    End
End Sub
Private Sub Reset()
    
    'Close any open connections
    db.Close

    'Initialize the program control values
    Timer1.Enabled = False
    Timer1.Interval = 250
    'Image1.Tag = 2
    Label1.Visible = True
    Label2.Visible = True
    Grid.Visible = False
    Label_Top.Visible = False
    Text_Top.Visible = False
    Label_Mid.Caption = "User ID"
    Label_Mid.Visible = False
    Text_Mid.Visible = False
    Text_Mid.Enabled = True
    Label_Bot.Caption = "Password"
    Label_Bot.Visible = False
    Text_Bot.Visible = False
    Text_Bot.PasswordChar = "*"

'    Set Image1.Picture = LoadResPicture(102, vbResBitmap)
    
    Text_Top.Text = sServer
    Text_Mid.Text = sLoginID
    Text_Bot.Text = sPassword
    
    Label1.Caption = sCase0_UpperText
    Label2.Caption = sCase0_LowerText
    Timer1.Enabled = True

End Sub

Private Sub Command_Next_Click()

    Select Case nState
        
        Case 1

            'Get the Server, Login and Password that are required to connect
            nState = nState + 1
            Label1.Visible = False
            Label_Top.Visible = True
            Label_Mid.Visible = True
            Label_Bot.Visible = True
            Text_Top.Visible = True
            Text_Mid.Visible = True
            Text_Bot.Visible = True
            Text_Top.SetFocus
            Label2.Caption = sCase1_LowerText
       Case 2
            sServer = Text_Top.Text
            sLoginID = Text_Mid.Text
            sPassword = Text_Bot.Text
            ConnectLinkedTable
            nState = nState + 1
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase2_UpperText
            Label2.Caption = sCase2_LowerText
        Case 3
            CreateLinkedTable
            nState = nState + 1
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Text = ""
            Text_Mid.Text = ""
            Text_Bot.Text = ""
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase3_UpperText
            Label2.Caption = sCase3_LowerText
        Case 4
            DAOQuery
            nState = nState + 1
            Label1.Visible = False
            Grid.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label2.Caption = sCase4_LowerText
        Case 5
            DAORecordSetFindFirst
            nState = nState + 1
            Label1.Visible = False
            Grid.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label2.Caption = sCase5_LowerText
        Case 6
            DAORecordSetFindNext
            nState = nState + 1
            Grid.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label2.Caption = sCase6_LowerText
        Case 7
            DAORecordsetFindLast
            nState = nState + 1
            Grid.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label2.Caption = sCase7_LowerText
        Case 8
            DAOLimitedRecordSet
            nState = nState + 1
            Grid.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label2.Caption = sCase8_LowerText
        Case 9
            CreateTable
            nState = nState + 1
            Grid.Visible = False
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase9_UpperText
            Label2.Caption = sCase9_LowerText
        Case 10
            AddUsingRecordset
            nState = nState + 1
            Grid.Visible = True
            Label1.Visible = False
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase10_UpperText
            Label2.Caption = sCase10_LowerText
        Case 11
            UpdateUsingRecordset
            nState = nState + 1
            Grid.Visible = True
            Label1.Visible = False
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase11_UpperText
            Label2.Caption = sCase11_LowerText
        Case 12
            DeleteUsingRecordset
            nState = nState + 1
            Grid.Visible = True
            Label1.Visible = False
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase12_UpperText
            Label2.Caption = sCase12_LowerText
        Case 13
            AddUsingInsert
            nState = nState + 1
            Grid.Visible = False
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase13_UpperText
            Label2.Caption = sCase13_LowerText
        Case 14
            UpdateUsingUpdate
            nState = nState + 1
            Grid.Visible = False
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase14_UpperText
            Label2.Caption = sCase14_LowerText
         Case 15
            DeleteUsingDelete
            nState = nState + 1
            Grid.Visible = False
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase15_UpperText
            Label2.Caption = sCase15_LowerText
         Case 16
            ShowError
            nState = nState + 1
            Grid.Visible = False
            Label1.Visible = True
            Label_Top.Visible = False
            Label_Mid.Visible = False
            Label_Bot.Visible = False
            Text_Top.Visible = False
            Text_Mid.Visible = False
            Text_Bot.Visible = False
            Label1.Caption = sCase16_UpperText
            Label2.Caption = sCase16_LowerText
        Case 17
            Finish
        End Select

End Sub

Private Sub Form_Load()
    
    'Initial the program control values
    nState = 1
    Label_Top.Visible = False
    Text_Top.Visible = False
    Label_Mid.Visible = False
    Text_Mid.Visible = False
    Label_Bot.Visible = False
    Text_Bot.Visible = False
    Grid.Visible = False
    
    Grid.Rows = 1
    Grid.Cols = 2
    Grid.Row = 0


    
    Label1.Caption = sCase0_UpperText
    Label2.Caption = sCase0_LowerText
    
End Sub

Private Sub DisplayDynasetGrid(rs As Recordset, Grid As MSFlexGrid, nDirection As Integer)
    
    Dim fld As Field
    Dim nForward As Integer
    Dim nReverse As Integer
    On Error Resume Next
    
    nForward = 1
    nReverse = 2
    
    ' Setup the grid
    Grid.Cols = rs.Fields.Count
    rs.MoveLast
    Grid.Rows = rs.RecordCount + 1
    Grid.Row = 0
    Grid.Col = 0
    Grid.FixedRows = 1
    Grid.Clear
            
    'Setup the Grid headings
     For Each fld In rs.Fields
         If rs.EOF = False Then
            Grid.ColWidth(Grid.Col) = TextWidth(String(Len(fld.Name) + 4, "a"))
         End If
         Grid.Col = fld.OrdinalPosition
         Grid.Text = fld.Name
         Grid.ColAlignment(Grid.Col) = 1
    Next fld
    
     
    If nDirection = nForward Then
    
        rs.MoveFirst
    
        ' Move through each row in the record set
        Do Until rs.EOF
        
            ' Set the position in the grid
            Grid.Row = Grid.Row + 1
            Grid.Col = 0
        
            'Loop through all fields
            For Each fld In rs.Fields
                Grid.Col = fld.OrdinalPosition
                If Grid.ColWidth(Grid.Col) < TextWidth(String(Len(fld.Value) + 4, "a")) Then
                    Grid.ColWidth(Grid.Col) = TextWidth(String(Len(fld.Value) + 4, "a"))
                End If
                Grid.Text = fld.Value
            Next fld
    
            rs.MoveNext
        Loop

    Else

        rs.MoveLast
        
        ' Move through each row in the record set
        Do Until rs.BOF
        
            ' Set the position in the grid
            Grid.Row = Grid.Row + 1
            Grid.Col = 0
        
            'Loop through all fields
            For Each fld In rs.Fields
                Grid.Col = fld.OrdinalPosition
                If Grid.ColWidth(Grid.Col) < TextWidth(String(fld.Size + 4, "a")) Then
                    Grid.ColWidth(Grid.Col) = TextWidth(String(fld.Size + 4, "a"))
                End If
                Grid.Text = fld.Value
            Next fld
    
            rs.MovePrevious
            
        Loop

    End If
    
End Sub

Private Sub DisplayDAOError()
        
    Dim er As Error
    
    For Each er In Errors
        MsgBox "Number: " & er.Number & vbCrLf & _
        "Source: " & er.Source & vbCrLf & _
        "Text: " & er.Description
    Next
        
End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    On Error Resume Next
    
    Set DBEngine = Nothing
    
End Sub

Private Sub Command_Cancel_Click()
    
    End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -