วันเสาร์ที่ 10 กันยายน พ.ศ. 2554

VB and MS-Access

กันลืม

-----------------------------------------------

แปลงตัวอักษรเวลาพิมพ์ จากตัวเล็กให้เป็นตัวใหญ่ให้หมด

ใช้ได้ทั้ง VB และ VBA คุณเพียงเปลี่ยน Text1 เป็น ชื่อที่คุณใช้

อ้างอิง...... http://support.microsoft.com/kb/84059


Sub Text1_Change ()
   ' Get the current position of the cursor.
             CurrStart = Text1.SelStart
    ' Change the text to capitals.
            Text1.Text = UCase$(Text1.Text)
    ' Reset the cursor position.
            Text1.SelStart = CurrStart
End Sub


----------------------------------------------------------


for Visual basic, text box เมื่อ focut ไปที่ text box แล้วให้ทำการ hilight ข้อมูลที่อยู่ใน Text box นั้น

อ้างอิง.... http://support.microsoft.com/kb/161240/en-us
Step-by-Step Example
1.Start Visual Basic, or, if it is already running, click New Project from the File menu.
2.Place two Text Boxes on the Form1 form with the default settings. 3.Copy and paste the following code to the Form1 Code Window:

Private Sub Text1_GotFocus()
     Call SelectMe(Me.ActiveControl)
End Sub


Private Sub Text2_GotFocus()
     Call SelectMe(Me.ActiveControl)
End Sub

Private Sub SelectMe(This As TextBox)
     This.SelStart = 0
     This.SelLength = Len(This.Text)
End Sub
-----------------------------------------------------------------

VB
ปุ่มลูกศร ซ้ายขวา ขึ้นลง

อ้างอิง... http://support.microsoft.com/kb/100413/en-us
Private Sub txtQTY_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
       Case 37 ‘Left กดปุ่มลูกศรซ้าย
              text1.SetFocus
      Case 39 ‘ Right กดปุ่มลูกศรขวา
              text2.SetFocus
      Case 38 ‘Up กดปุ่มลูกศรขึ้น
              text3.SetFocus
      Case 40 ‘Down กดปุ่มลูกศรลง
              text4.SetFocus
   End Select
End sub

ไม่มีความคิดเห็น: