Jetzt habe ich folgenden Code geschrieben und ein Objekt CommonDialog1
der Klasse CommonDialog definiert:
1 | Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
|
2 | Dim sFile As String
|
3 | Dim ProgMemAddrH As Long
|
4 | Dim command(5) As Byte
|
5 | Dim writeFail As Boolean
|
6 | Dim CommonDialog1 As CommonDialog
|
7 | Dim RetStat As String
|
8 | Dim test As String
|
9 | Dim MyButtons As String
|
10 |
|
11 | Select Case Button.Key
|
12 | Case "Open"
|
13 |
|
14 |
|
15 |
|
16 | 'With CommonDialog1
|
17 | CommonDialog1.DialogTitle = "Open HEX File"
|
18 | CommonDialog1.CancelError = False
|
19 | CommonDialog1.Flags = cdlOFNHideReadOnly
|
20 | CommonDialog1.Filter = "INHEX32 Files (*.HEX)|*.HEX|All Files (*.*)|*.*"
|
21 | CommonDialog1.ShowOpen
|
22 | If Len(CommonDialog1.FileName) = 0 Then
|
23 | Exit Sub
|
24 | End If
|
25 |
|
26 | PicBootS.InFileName = CommonDialog1.FileName
|
27 | CommonDialog1.FileName = ""
|
28 | 'End With
|
29 |
|
30 |
|
31 | RetStat = ImportP24HEXFile(PicBootS.InFileName)
|
32 |
|
33 |
|
34 | If RetStat = -2 Then
|
35 | StatusBar1.Panels(PANEL_STATUS).Text = STATUS_HEX_FORMAT
|
36 | Else
|
37 | If RetStat > 0 Then
|
38 | StatusBar1.Panels(PANEL_STATUS).Text = STATUS_HEX_IMPORTED
|
39 | Else
|
40 | StatusBar1.Panels(PANEL_STATUS).Text = STATUS_INVALID_HEX
|
41 | End If
|
42 | End If
|
Die "With" Sintax Syntax habe ich mal ausskommentiert.
Nun erhalte ich aber "Laufzeitfehler 91: Objektvariable oder
With-Blockvariable nicht festgelegt" wenn ich auf Open Button drücke...
Die gleiche Fehlermeldung erhalte ich, wenn der With-Block drin ist...
Eben wie gesagt, ich bin ziemlich ein Anfgänger in VB, also sind
konstruktive Bemerkungen gewünscht...