F
Fiona
I would like to recreate a collection of VBA forms in VB6 but the
result runs very slowly when ever I change the contents of a text box
on the VB6 version.
I've tried early binding (not sure if its quite right) seems to be
different ways ?
Below are 2 sets of code, the first the VB form, second the Excel VBA
form.
The VB6 form works but has a slight hang whenever you enter a value.
Any help gratefully recieved.
VB6
----
Declarations
-------------
Dim ObjExcel As Excel.Application
------------------------------------------
Private Sub Form Load
Set ObjExcel = New Excel.Application
ObjExcel.Workbooks.Open (Path & "\" & MyFolder & "\" & MyFile)
ObjExcel.Visible = False
End Sub
--------------------------------------------------
Private Sub CboShops_Change()
X = CboShops.ListIndex + 8
h = CboShops.ListIndex + 9
TxtD.Text = Worksheets(1).Cells(X, 3).Text
TxtDT.Text = Worksheets(1).Cells(X, 4).Text
LblDTP.Caption = Worksheets(1).Cells(X, 5).Text
TxtDY.Text = Worksheets(1).Cells(X, 6).Text
LblDYP.Caption = Worksheets(1).Cells(X, 7).Text
TxtB.Text = Worksheets(1).Cells(X, 8).Text
TxtBT.Text = Worksheets(1).Cells(X, 9).Text
LblBTP.Caption = Worksheets(1).Cells(X, 10).Text
TxtBY.Text = Worksheets(1).Cells(X, 11).Text
LblBYP.Caption = Worksheets(1).Cells(X, 12).Text
TxtC.Text = Worksheets(1).Cells(X, 13).Text
TxtCT.Text = Worksheets(1).Cells(X, 14).Text
LblCTP.Caption = Worksheets(1).Cells(X, 15).Text
TxtCY.Text = Worksheets(1).Cells(X, 16).Text
LblCYP.Caption = Worksheets(1).Cells(X, 17).Text
LblT.Caption = Worksheets(1).Cells(X, 18).Text
LblTT.Caption = Worksheets(1).Cells(X, 19).Text
LblTTP.Caption = Worksheets(1).Cells(X, 20).Text
LblTY.Caption = Worksheets(1).Cells(X, 21).Text
LblTYP.Caption = Worksheets(1).Cells(X, 22).Text
TxtH.Text = Worksheets(2).Cells(h, 4).Text
TxtNH.Text = Worksheets(2).Cells(h, 5).Text
End Sub
------------------------------------------------------------
Private Sub TxtB_Change()
X = CboShops.ListIndex + 8
If X <> 26 Then
If IsNumeric(TxtB.Text) = False And TxtB.Text <> "" Then
MsgBox "Numbers Only Please", vbExclamation + vbOKOnly
TxtB.Text = ""
TxtB.SetFocus
Else
Worksheets(1).Cells(X, 8).Value = TxtB.Text
CboShops_Change
End If
End If
End Sub
***********************************************************************
***********************************************************************
Excel App
---------------
Workbook code:
---------------
Private Sub Workbook_Open()
FrmArea.Show
End Sub
----------------------------------------------
User Form Code:
---------------
Private Sub CboShops_Change()
X = CboShops.ListIndex + 8
h = CboShops.ListIndex + 9
TxtD.Text = Worksheets(1).Cells(X, 3).Text
TxtDT.Text = Worksheets(1).Cells(X, 4).Text
LblDTP.Caption = Worksheets(1).Cells(X, 5).Text
TxtDY.Text = Worksheets(1).Cells(X, 6).Text
LblDYP.Caption = Worksheets(1).Cells(X, 7).Text
TxtB.Text = Worksheets(1).Cells(X, 8).Text
TxtBT.Text = Worksheets(1).Cells(X, 9).Text
LblBTP.Caption = Worksheets(1).Cells(X, 10).Text
TxtBY.Text = Worksheets(1).Cells(X, 11).Text
LblBYP.Caption = Worksheets(1).Cells(X, 12).Text
TxtC.Text = Worksheets(1).Cells(X, 13).Text
TxtCT.Text = Worksheets(1).Cells(X, 14).Text
LblCTP.Caption = Worksheets(1).Cells(X, 15).Text
TxtCY.Text = Worksheets(1).Cells(X, 16).Text
LblCYP.Caption = Worksheets(1).Cells(X, 17).Text
LblT.Caption = Worksheets(1).Cells(X, 18).Text
LblTT.Caption = Worksheets(1).Cells(X, 19).Text
LblTTP.Caption = Worksheets(1).Cells(X, 20).Text
LblTY.Caption = Worksheets(1).Cells(X, 21).Text
LblTYP.Caption = Worksheets(1).Cells(X, 22).Text
TxtH.Text = Worksheets(2).Cells(h, 4).Text
TxtNH.Text = Worksheets(2).Cells(h, 5).Text
End Sub
----------------------------------------------------
Private Sub TxtB_Change()
X = CboShops.ListIndex + 8
If X <> 26 Then
If IsNumeric(TxtB.Text) = False And TxtB.Text <> "" Then
MsgBox "Numbers Only Please", vbExclamation + vbOKOnly
TxtB.Text = ""
TxtB.SetFocus
Else
Worksheets(1).Cells(X, 8).Value = TxtB.Text
CboShops_Change
End If
End If
End Sub
result runs very slowly when ever I change the contents of a text box
on the VB6 version.
I've tried early binding (not sure if its quite right) seems to be
different ways ?
Below are 2 sets of code, the first the VB form, second the Excel VBA
form.
The VB6 form works but has a slight hang whenever you enter a value.
Any help gratefully recieved.
VB6
----
Declarations
-------------
Dim ObjExcel As Excel.Application
------------------------------------------
Private Sub Form Load
Set ObjExcel = New Excel.Application
ObjExcel.Workbooks.Open (Path & "\" & MyFolder & "\" & MyFile)
ObjExcel.Visible = False
End Sub
--------------------------------------------------
Private Sub CboShops_Change()
X = CboShops.ListIndex + 8
h = CboShops.ListIndex + 9
TxtD.Text = Worksheets(1).Cells(X, 3).Text
TxtDT.Text = Worksheets(1).Cells(X, 4).Text
LblDTP.Caption = Worksheets(1).Cells(X, 5).Text
TxtDY.Text = Worksheets(1).Cells(X, 6).Text
LblDYP.Caption = Worksheets(1).Cells(X, 7).Text
TxtB.Text = Worksheets(1).Cells(X, 8).Text
TxtBT.Text = Worksheets(1).Cells(X, 9).Text
LblBTP.Caption = Worksheets(1).Cells(X, 10).Text
TxtBY.Text = Worksheets(1).Cells(X, 11).Text
LblBYP.Caption = Worksheets(1).Cells(X, 12).Text
TxtC.Text = Worksheets(1).Cells(X, 13).Text
TxtCT.Text = Worksheets(1).Cells(X, 14).Text
LblCTP.Caption = Worksheets(1).Cells(X, 15).Text
TxtCY.Text = Worksheets(1).Cells(X, 16).Text
LblCYP.Caption = Worksheets(1).Cells(X, 17).Text
LblT.Caption = Worksheets(1).Cells(X, 18).Text
LblTT.Caption = Worksheets(1).Cells(X, 19).Text
LblTTP.Caption = Worksheets(1).Cells(X, 20).Text
LblTY.Caption = Worksheets(1).Cells(X, 21).Text
LblTYP.Caption = Worksheets(1).Cells(X, 22).Text
TxtH.Text = Worksheets(2).Cells(h, 4).Text
TxtNH.Text = Worksheets(2).Cells(h, 5).Text
End Sub
------------------------------------------------------------
Private Sub TxtB_Change()
X = CboShops.ListIndex + 8
If X <> 26 Then
If IsNumeric(TxtB.Text) = False And TxtB.Text <> "" Then
MsgBox "Numbers Only Please", vbExclamation + vbOKOnly
TxtB.Text = ""
TxtB.SetFocus
Else
Worksheets(1).Cells(X, 8).Value = TxtB.Text
CboShops_Change
End If
End If
End Sub
***********************************************************************
***********************************************************************
Excel App
---------------
Workbook code:
---------------
Private Sub Workbook_Open()
FrmArea.Show
End Sub
----------------------------------------------
User Form Code:
---------------
Private Sub CboShops_Change()
X = CboShops.ListIndex + 8
h = CboShops.ListIndex + 9
TxtD.Text = Worksheets(1).Cells(X, 3).Text
TxtDT.Text = Worksheets(1).Cells(X, 4).Text
LblDTP.Caption = Worksheets(1).Cells(X, 5).Text
TxtDY.Text = Worksheets(1).Cells(X, 6).Text
LblDYP.Caption = Worksheets(1).Cells(X, 7).Text
TxtB.Text = Worksheets(1).Cells(X, 8).Text
TxtBT.Text = Worksheets(1).Cells(X, 9).Text
LblBTP.Caption = Worksheets(1).Cells(X, 10).Text
TxtBY.Text = Worksheets(1).Cells(X, 11).Text
LblBYP.Caption = Worksheets(1).Cells(X, 12).Text
TxtC.Text = Worksheets(1).Cells(X, 13).Text
TxtCT.Text = Worksheets(1).Cells(X, 14).Text
LblCTP.Caption = Worksheets(1).Cells(X, 15).Text
TxtCY.Text = Worksheets(1).Cells(X, 16).Text
LblCYP.Caption = Worksheets(1).Cells(X, 17).Text
LblT.Caption = Worksheets(1).Cells(X, 18).Text
LblTT.Caption = Worksheets(1).Cells(X, 19).Text
LblTTP.Caption = Worksheets(1).Cells(X, 20).Text
LblTY.Caption = Worksheets(1).Cells(X, 21).Text
LblTYP.Caption = Worksheets(1).Cells(X, 22).Text
TxtH.Text = Worksheets(2).Cells(h, 4).Text
TxtNH.Text = Worksheets(2).Cells(h, 5).Text
End Sub
----------------------------------------------------
Private Sub TxtB_Change()
X = CboShops.ListIndex + 8
If X <> 26 Then
If IsNumeric(TxtB.Text) = False And TxtB.Text <> "" Then
MsgBox "Numbers Only Please", vbExclamation + vbOKOnly
TxtB.Text = ""
TxtB.SetFocus
Else
Worksheets(1).Cells(X, 8).Value = TxtB.Text
CboShops_Change
End If
End If
End Sub