Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Date

  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Malaysia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date

    Dear Sir,

    In VB 6.0.

    (a) How can I display the current month and year in the list of combo box (mmmm YYYY). Should I need to use the system date, if yes what is the coding? (Note: I refuse to type-in the current date in the combo list, because it is unable to update the date )

    (b)I want to let the user to create the customer code as below:
    For Example : 3000/T01
    but I don't want let the cursor accross the "/" sign, so that user unable to make any changes for it. How is the coding???

    (c) How can I make the new line in the label control?
    For example, I have two sentences now, but I want to display its in two line as below:
    Version: 1.0
    Developed By: ABC Company


    Thank,


    Xiang


    Xiang

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (c) I don't know if you can do it by editing the property in the design view, but you could do it easily in code:
    Code:
    Private Sub Form_Load()
        lblVersion.Caption = "Version: 1.0" & vbCrLf & "Developed By: ABC Company"
    End Sub
    (b) Not exactly what you're asking for but I think it's close enough. In the KeyPress event of the textbox you can check if he's going to edit the uneditable part using Instr to get the position of the slash, and comparing it to SelStart, then cancel the keypress by setting the code to 0:
    Code:
    Private Sub txtCode_KeyPress(KeyAscii As Integer)
        Dim pos As Integer
        pos = InStr(txtCode.Text, "/") ' get '/' position
        If txtCode.SelStart > pos Then
            KeyAscii = 0 ' cancel this keypress
            txtCode.SelStart = pos - 1 ' reset cursor to before the '/'
        End If
    End Sub
    (a) I didn't really understand the question.

    shmoove


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •