mcochrane123
07-18-2022, 10:05 AM
Afternoon All,
I can't seem to forum/stackoverflow research where I am going wrong on this code. I don't often use Listboxes so I am not familiar with their pit falls.
What I am trying to do with the sub is to write values from the form to a list box for final review before writing to the workbook.
The program does everything until it hits
.list(i,10) and spits out a 'runtime error 380, could not set the list property. Invalid property value.' I get this impression its something to do with initialization of the list because when use the immediate window for
.list(i,9) it works find but
.list(i,10) same runtime error.
If anyone could help I kind of at a loss.
Private Sub UserForm_Initialize()
With Me
.CboBSize.List = Split("10m,15m,20m,25m", ",")
.CboBType.List = Split("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28, 29,30,31,32,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,T1,T2,T3,T4, T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,X", ",")
.CboGrade.List = Split("400,500,SS520", ",")
.CboRNumb.List = Split("001,002,003,004,005,006,007,008,009,010", ",")
End With
With Me.LstPreviousEntry
.ColumnCount = 21
.ColumnWidths = "26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26"
.Clear
End With
End Sub
Private Sub BtnNext_Click()
Dim i As Integer
Dim bl As String
i = Me.LstPreviousEntry.ListCount
'bl = SumBars(Me.TglMeasure.Value, Me)
If i = 0 Then
With Me.LstPreviousEntry
.AddItem
.List(i, 0) = Me.TxtDwgSht.Value
.List(i, 1) = Me.CboRNumb.Value
.List(i, 2) = Me.TxtBarMark.Value
.List(i, 3) = Me.CboGrade.Value
.List(i, 4) = Me.CboBSize.Value
.List(i, 5) = Me.TxtBarNum
'.List(i, 6) = bl
'.List(i, 7) = TotalBar(bl, Me.TxtBarNum, Me.TglMeasure.Value)
.List(i, 8) = Me.CboBType.Value
'.additem(i,9) = WEIGHT LOOK UP TABLE
.List(i, 10) = 1
.List(i, 11) = Me.TxtB.Value
.List(i, 12) = Me.TxtC.Value
.List(i, 13) = Me.TxtD.Value
.List(i, 14) = Me.TxtE.Value
.List(i, 15) = Me.TxtF.Value
.List(i, 16) = Me.TxtG.Value
.List(i, 17) = Me.TxtH.Value
.List(i, 18) = Me.TxtJ.Value
.List(i, 19) = Me.TxtK.Value
.List(i, 20) = Me.TxtO.Value
.List(i, 21) = Me.TxtR.Value
End With
Else
With Me.LstPreviousEntry
i = .ListCount + 1
.AddItem
.List(i, 0) = Me.TxtDwgSht.Value
.List(i, 1) = Me.CboRNumb.Value
.List(i, 2) = Me.TxtBarMark.Value
.List(i, 3) = Me.CboGrade.Value
.List(i, 4) = Me.CboBSize.Value
.List(i, 5) = Me.TxtBarNum
'.List(i, 6) = bl
'.List(i, 7) = TotalBar(bl, Me.TxtBarNum, Me.TglMeasure.Value)
.List(i, 8) = Me.CboBType.Value
'.additem(i,9) = WEIGHT LOOK UP TABLE
.List(i, 10) = Me.TxtA
.List(i, 11) = Me.TxtB
.List(i, 12) = Me.TxtC
.List(i, 13) = Me.TxtD
.List(i, 14) = Me.TxtE
.List(i, 15) = Me.TxtF
.List(i, 16) = Me.TxtG
.List(i, 17) = Me.TxtH
.List(i, 18) = Me.TxtJ
.List(i, 19) = Me.TxtK
.List(i, 20) = Me.TxtO
.List(i, 21) = Me.TxtR
End With
End If
End Sub
I can't seem to forum/stackoverflow research where I am going wrong on this code. I don't often use Listboxes so I am not familiar with their pit falls.
What I am trying to do with the sub is to write values from the form to a list box for final review before writing to the workbook.
The program does everything until it hits
.list(i,10) and spits out a 'runtime error 380, could not set the list property. Invalid property value.' I get this impression its something to do with initialization of the list because when use the immediate window for
.list(i,9) it works find but
.list(i,10) same runtime error.
If anyone could help I kind of at a loss.
Private Sub UserForm_Initialize()
With Me
.CboBSize.List = Split("10m,15m,20m,25m", ",")
.CboBType.List = Split("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28, 29,30,31,32,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,T1,T2,T3,T4, T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,X", ",")
.CboGrade.List = Split("400,500,SS520", ",")
.CboRNumb.List = Split("001,002,003,004,005,006,007,008,009,010", ",")
End With
With Me.LstPreviousEntry
.ColumnCount = 21
.ColumnWidths = "26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26;26"
.Clear
End With
End Sub
Private Sub BtnNext_Click()
Dim i As Integer
Dim bl As String
i = Me.LstPreviousEntry.ListCount
'bl = SumBars(Me.TglMeasure.Value, Me)
If i = 0 Then
With Me.LstPreviousEntry
.AddItem
.List(i, 0) = Me.TxtDwgSht.Value
.List(i, 1) = Me.CboRNumb.Value
.List(i, 2) = Me.TxtBarMark.Value
.List(i, 3) = Me.CboGrade.Value
.List(i, 4) = Me.CboBSize.Value
.List(i, 5) = Me.TxtBarNum
'.List(i, 6) = bl
'.List(i, 7) = TotalBar(bl, Me.TxtBarNum, Me.TglMeasure.Value)
.List(i, 8) = Me.CboBType.Value
'.additem(i,9) = WEIGHT LOOK UP TABLE
.List(i, 10) = 1
.List(i, 11) = Me.TxtB.Value
.List(i, 12) = Me.TxtC.Value
.List(i, 13) = Me.TxtD.Value
.List(i, 14) = Me.TxtE.Value
.List(i, 15) = Me.TxtF.Value
.List(i, 16) = Me.TxtG.Value
.List(i, 17) = Me.TxtH.Value
.List(i, 18) = Me.TxtJ.Value
.List(i, 19) = Me.TxtK.Value
.List(i, 20) = Me.TxtO.Value
.List(i, 21) = Me.TxtR.Value
End With
Else
With Me.LstPreviousEntry
i = .ListCount + 1
.AddItem
.List(i, 0) = Me.TxtDwgSht.Value
.List(i, 1) = Me.CboRNumb.Value
.List(i, 2) = Me.TxtBarMark.Value
.List(i, 3) = Me.CboGrade.Value
.List(i, 4) = Me.CboBSize.Value
.List(i, 5) = Me.TxtBarNum
'.List(i, 6) = bl
'.List(i, 7) = TotalBar(bl, Me.TxtBarNum, Me.TglMeasure.Value)
.List(i, 8) = Me.CboBType.Value
'.additem(i,9) = WEIGHT LOOK UP TABLE
.List(i, 10) = Me.TxtA
.List(i, 11) = Me.TxtB
.List(i, 12) = Me.TxtC
.List(i, 13) = Me.TxtD
.List(i, 14) = Me.TxtE
.List(i, 15) = Me.TxtF
.List(i, 16) = Me.TxtG
.List(i, 17) = Me.TxtH
.List(i, 18) = Me.TxtJ
.List(i, 19) = Me.TxtK
.List(i, 20) = Me.TxtO
.List(i, 21) = Me.TxtR
End With
End If
End Sub