機房收費系統-最佳化

來源:互聯網
上載者:User
在機房收費系統基本表單實現以後進行整體的最佳化。

比如一些介面的美化、控制項的大小和字型、控制項是否可以輸入、控制項的輸入條件—(數字、字母、漢字)、清空等 整體的父子表單的大小 msflexgrid控制項隨內容的大小變化而變化 時間控制項和資料庫中時間格式是否一致

列舉部分問題及其解決方案如下:

1.dtpicker控制項的時間和日期格式設定

Private Sub DTP1_Change()'如果選擇上下機日期If Trim(Comfield1.Text) = "上機日期" Or Trim(Comfield1.Text) = "下機日期" Then    Text1.Text = DTP1.ValueElse    If Trim(Comfield1.Text) = "上機時間" Or Trim(Comfield1.Text) = "下機時間" Then        '將dtpicker控制項改為time格式,並可見        DTP1.Format = dtpTime        DTP1.Value = Time        Text1.Text = DTP1.Value    End IfEnd IfEnd Sub

2.選中表並更改顏色,格式

Dim col As Integer     If MSFlexGrid1.Rows < 2 Then          Exit Sub    End If        If MSFlexGrid1.row < 1 Or MSFlexGrid1.row > MSFlexGrid1.Rows - 1 Then           Exit Sub    End If             If MSFlexGrid1.TextMatrix(MSFlexGrid1.row, 0) = "√" Then            MSFlexGrid1.TextMatrix(MSFlexGrid1.row, 0) = ""            '改變行顏色(變為沒選中之前的)      For col = 0 To MSFlexGrid1.Cols - 1      MSFlexGrid1.col = col      MSFlexGrid1.CellBackColor = vbWhite      Next col  Else          MSFlexGrid1.TextMatrix(MSFlexGrid1.row, 0) = "√"            '改變行顏色(選中後的顏色)     For col = 0 To MSFlexGrid1.Cols - 1     MSFlexGrid1.col = col     MSFlexGrid1.CellBackColor = vbRed     Next col     End If
3.時間比較,時間格式設定

Private Sub DTPicker1_Change()    DTPicker1.Format = dtpCustom    DTPicker1.CustomFormat = "yyyy-MM-dd" '設定DTPicker控制項的顯示格式為yyyy-MM-dd格式        date1 = DTPicker1.Value    date2 = DTPicker2.Value    date3 = Format(Date, "yyyy-MM-dd") '獲得實際日期         '比較起始日期和實際日期的大小    If DateDiff("n", CDate(date1), CDate(date3)) < 0 Then        MsgBox "超過規定日期,請重新選擇日期。", vbOKOnly + vbExclamation, "提示"        Exit Sub    End If    
4.設定msflexgrid控制項的各個列寬

代碼一:

Private Sub Form_Load()        '設定msflexgrid控制項的寬度    MSFlexGrid1.ColWidth(0) = 800    MSFlexGrid1.ColWidth(1) = 2000    MSFlexGrid1.ColWidth(2) = 2000    MSFlexGrid1.ColWidth(3) = 2000    MSFlexGrid1.ColWidth(4) = 2000End Sub

代碼二:

'目的隨著內容改變更改列的寬的Public Sub AdjustColWidth(frmCur As Form, gridCur As Object, Optional bNullRow As Boolean = True, 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 WithEnd Sub調用函數:AdjustColWidth frminquiryrechargerecord, MSFlexGrid1





相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.