after the basic form of the computer room charge system is implemented, the overall optimization.
such as the beautification of some interfaces, the size and font of the control, whether the control can be entered, the input criteria for the control-(numbers, letters, kanji), the size of the overall parent-child form MSFlexGrid The control varies with the size of the content, and the time format of the time control and database is consistent
list Some of the problems and their solutions are as follows:
Time and date format settings for 1.dtpicker controls
Private Sub dtp1_change ()
' If select up and down date if
Trim (comfield1.text) = "On machine date" Or Trim (Comfield1.text) = "Machine Date"
then Text1.Text = DTP1. Value
Else
If trim (comfield1.text) = "On machine Time" Or trim (comfield1.text) = "Down Time" then "
changes the DTPicker control to the
DTP1. Format = Dtptime
DTP1. Value = time
Text1.Text = DTP1. Value
End If End
if
end Sub
2. Select the table and change the color, format
Dim Col as Integer
if msflexgrid1.rows < 2 then
Exit Sub
End if
if Msflexgrid1.row < 1 Or MSFlexGrid 1.row > Msflexgrid1.rows-1 then
Exit Sub
End if
if Msflexgrid1.textmatrix (msflexgrid1.row, 0) = "√" then< C7/>msflexgrid1.textmatrix (msflexgrid1.row, 0) = "" "
changes the row color (before it has been selected) for
col = 0 to Msflexgrid1.cols-1
Msflexgrid1.col = col
msflexgrid1.cellbackcolor = vbwhite
Next col
Else
Msflexgrid1.textmatrix ( Msflexgrid1.row, 0) = "√"
' Change row color (selected color) for
col = 0 to msflexgrid1.cols-1
msflexgrid1.col = col
MSF Lexgrid1.cellbackcolor = vbred
Next col
End If
3. Time comparison, time format settings
Private Sub dtpicker1_change ()
Dtpicker1.format = dtpcustom
Dtpicker1.customformat = "Yyyy-mm-dd" ' Set the display format of the DTPicker control to YYYY-MM-DD format
date1 = dtpicker1.value
date2 = dtpicker2.value
date3 = Format (Date, " Yyyy-mm-dd ") ' Get actual date
' compare start date and actual date size
If DateDiff (" n ", CDate (Date1), CDate (date3)) < 0 then
MsgBox" Please re-select the date if it exceeds the specified date. ", vbOKOnly + vbexclamation," hint "
Exit Sub
End If
4. Set the width of each column of the MSFlexGrid control
Code One:
Private Sub Form_Load ()
' Sets the width of the MSFlexGrid control
msflexgrid1.colwidth (0) =
msflexgrid1.colwidth (1) =
msflexgrid1.colwidth (2) =
Msflexgrid1.colwidth (3) =
Msflexgrid1.colwidth (4) = 2000
End Sub
Code two:
' Purpose changes the width of the column as the content changes the public
Sub adjustcolwidth (frmcur as Form,
gridcur as Object,
Optional bnullrow as Boolean = T Rue,
Optional dblincwidth as Double = 0)
Dim i As Integer
Dim j As Integer
Dim dblwidth As Double
with Gridcur ' msflexgrid1 for
i = 0 to. Cols-1
dblwidth = 0
If. Colwidth (i) <> 0 Then for
j = 0 to. Rows-1
If frmcur.textwidth (. Textmatrix (J, i)) > dblwidth then
dblwidth = Frmcur.textwidth (. Textmatrix (J, i))
End If
Next J
. Colwidth (i) = dblwidth + dblincwidth + 550
End If
Next i
end with
end Sub
Call function:
Adjustcolwidth Frminquiryrechargerecord, MSFlexGrid1