Computer room charging System-optimization

Source: Internet
Author: User
Tags date1 time and date trim
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





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.