?? frminput.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form2
Caption = "數據導入"
ClientHeight = 2160
ClientLeft = 60
ClientTop = 345
ClientWidth = 6615
LinkTopic = "Form2"
ScaleHeight = 2160
ScaleWidth = 6615
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "數據導入"
Height = 375
Left = 4920
TabIndex = 4
Top = 1560
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "檔案導入"
Height = 375
Left = 4920
TabIndex = 3
Top = 1200
Width = 1335
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 1440
Top = 2520
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command1
Height = 375
Left = 5880
TabIndex = 1
Top = 480
Width = 375
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 0
Text = "Text1"
Top = 480
Width = 4695
End
Begin VB.Label Label1
Caption = "表格路徑:"
Height = 375
Left = 240
TabIndex = 2
Top = 600
Width = 1095
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim Myfile
Dim FILE_PATH As String
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.Filter = "(*.xls)|*.xls"
' 指定缺省的過濾器
CommonDialog1.FilterIndex = 2
' 顯示“打開”對話框
CommonDialog1.ShowOpen
If Err.Number = 32755 Then GoTo ErrHandler:
Myfile = CommonDialog1.FileName
Text1.Text = Myfile
ErrHandler:
End Sub
Private Sub Command2_Click()
Dim xlApp As Object
Dim Sheet1 As Object
Dim new_value As String
Dim new_value1 As String
Dim row As Integer
Screen.MousePointer = vbHourglass
DoEvents
Set xlApp = CreateObject("excel.application")
xlApp.Workbooks.Open FileName:=Text1.Text
If VAL(xlApp.application.Version) >= 8 Then
Set Sheet1 = xlApp.activesheet
Else
Set Sheet1 = xlApp
End If
row = 1
Do
new_value = Trim$(Sheet1.cells(row, 1))
new_value1 = Trim$(Sheet1.cells(row, 2))
If Len(new_value) = 0 Then Exit Do
strsql = "insert into user1(HUHAO,NAME) values('" & _
new_value & "','" & new_value1 & "')"
On Error Resume Next
config.cnZdx.Execute strsql
row = row + 1
Loop
Set MYSET = Nothing
xlApp.activeworkbook.Close flase
xlApp.quit
Set xlApp = Nothing
Set xlSheet = Nothing
Screen.MousePointer = vbDefault
End Sub
Private Sub Command4_Click()
Dim Myfile
Dim FILE_PATH As String
CommonDialog1.CancelError = True
On Error GoTo ErrHandler:
CommonDialog1.Filter = "(*.xls)|*.mdb"
' 指定缺省的過濾器
CommonDialog1.FilterIndex = 2
' 顯示“打開”對話框
CommonDialog1.ShowOpen
If Err.Number = 32755 Then GoTo ErrHandler:
Myfile = CommonDialog1.FileName
Text2.Text = Myfile
ErrHandler:
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -