micky500970
Programmer
hello,
This is probably a daft question but here goes!
I am using a flex grid to store and edit data. Depending on what the user does determines how the grid will appear, for example, title, field size,grid size, colour, etc.
I keep all the amendments in subs and then call when required. the only snag is that I now have at least 7 subs now and it is making it hard to read my code. I just wondered if i could put the my subs in a class or something outside the form and then call it from there.This would save having all that extra code in my main form. I am self-taught and still very much a beginner. I have never used a class module before.
Any advice would be very much appreciated.
I have 7 subs, each having different settings.
Private Sub flexgrid1()
'lrgflag = 0
Dim s As String
Dim i As Integer
MSHFlexGrid.Visible = True
Set MSHFlexGrid1.DataSource = rs1
s = "<Region |^Ticket Number |^Status |^Location|^Department|^Date Open|^Short Description|^Priority|^Assigned To|^Ticket Submitter "
MSHFlexGrid1.FormatString = s
MSHFlexGrid1.WordWrap = True
MSHFlexGrid1.RowHeight(0) = 800
MSHFlexGrid1.Top = 5400
MSHFlexGrid1.Height = 3855
With MSHFlexGrid1
.Redraw = False
.ColWidth(0) = 1
.ColWidth(1) = 1000 'ticket number field
.ColWidth(4) = 1500 'location field
.ColWidth(5) = 1300 'date open field
.ColWidth(6) = 2700 'short description field
.ColWidth(7) = 1300 'priority field or date closed field
.ColWidth(9) = 1400
.ColWidth(10) = 0
' set grid's style
.AllowBigSelection = True
.FillStyle = flexFillRepeat
' grey every other row
For i = .FixedRows + 1 To .Rows - 1 Step 2
.row = i
.col = .FixedCols
.ColSel = .Cols() - .FixedCols
.CellBackColor = &HC0FFC0
'HC0C0C0 light grey
'HC0FFFF light yellow
'HFFFFC0 light blue
'HC0FFC0 light green
Next i
.AllowBigSelection = False
.FillStyle = flexFillSingle
.Redraw = True
End With
End Sub
This is probably a daft question but here goes!
I am using a flex grid to store and edit data. Depending on what the user does determines how the grid will appear, for example, title, field size,grid size, colour, etc.
I keep all the amendments in subs and then call when required. the only snag is that I now have at least 7 subs now and it is making it hard to read my code. I just wondered if i could put the my subs in a class or something outside the form and then call it from there.This would save having all that extra code in my main form. I am self-taught and still very much a beginner. I have never used a class module before.
Any advice would be very much appreciated.
I have 7 subs, each having different settings.
Private Sub flexgrid1()
'lrgflag = 0
Dim s As String
Dim i As Integer
MSHFlexGrid.Visible = True
Set MSHFlexGrid1.DataSource = rs1
s = "<Region |^Ticket Number |^Status |^Location|^Department|^Date Open|^Short Description|^Priority|^Assigned To|^Ticket Submitter "
MSHFlexGrid1.FormatString = s
MSHFlexGrid1.WordWrap = True
MSHFlexGrid1.RowHeight(0) = 800
MSHFlexGrid1.Top = 5400
MSHFlexGrid1.Height = 3855
With MSHFlexGrid1
.Redraw = False
.ColWidth(0) = 1
.ColWidth(1) = 1000 'ticket number field
.ColWidth(4) = 1500 'location field
.ColWidth(5) = 1300 'date open field
.ColWidth(6) = 2700 'short description field
.ColWidth(7) = 1300 'priority field or date closed field
.ColWidth(9) = 1400
.ColWidth(10) = 0
' set grid's style
.AllowBigSelection = True
.FillStyle = flexFillRepeat
' grey every other row
For i = .FixedRows + 1 To .Rows - 1 Step 2
.row = i
.col = .FixedCols
.ColSel = .Cols() - .FixedCols
.CellBackColor = &HC0FFC0
'HC0C0C0 light grey
'HC0FFFF light yellow
'HFFFFC0 light blue
'HC0FFC0 light green
Next i
.AllowBigSelection = False
.FillStyle = flexFillSingle
.Redraw = True
End With
End Sub