Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1

    Default VB Debugging Brain Freeze!!!... SHARE UR WISDOM...


    Hi there guys!

    Please help me gyud!... Have probs w/ my VB Debugging.
    The first If Block Statement did not function. Why?
    HELP ASAP!!! Gahi ulo ang vbKeyTab uy!

    ================================================== =
    Private Sub Text1_KeyPress(KeyAscii As Integer)

    If KeyAscii = vbKeyTab Then
    If Text1 = Null Then
    Â* Â* Â* Â* Text1.SetFocus
    Â* Â*Else
    Â* Â*KeyAscii = vbKeyTab
    Â* Â*End If
    End If

    End Sub
    ================================================== =

    Pls... Pls... Plsss... Reply ASAP! Urgent!
    Thank You Very Many!


    PM me... Email at poloyzki@yahoo.com... Mobile No.: 0920-5675863

    4U

  2. #2

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    have a breakpoint in your subroutine and try to see the value of your KeyAscii variable when you press TAB key and then change everything to If KeyAscii=<value> though its not a good programming practice to have magic numbers in your code maybe you can have it defined the value but dont know if naa #define macro sa VB. Good Luck.

  3. #3

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    yup..

    >>
    If KeyAscii = vbKeyTab Then ->> keyascii is for ascii code...

    try this.. replace the vbkeyTab with the ascii code/number

    Private Sub Form_KeyPress(KeyAscii As Integer)
    MsgBox KeyAscii
    End Sub

    if you want to know the ascii's for each character/keys..

  4. #4

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    I think theres a problem with KeyPress Event when executing vbKeyTab since it loses focus on the object text1. If above still doesn't work try changing your event to keyup / keydown etc. kung dili pa gyud try API though it will involve a lot of coding.

  5. #5

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    4U...

    this is not acceptable :

    If Text1 = Null Then

    try to change :

    if len(text1.text)=0 then



    hopes it works

  6. #6

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    Thanks 4 ur tips guys... Just taken down all your advices. I'll try them all.

    To: nunobone
    There is no keyascii code/number for the Tab Key.

    To: All
    Have to post if ever okey na or not.

    Please do keep in touch though... Thanks!

  7. #7

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    try making a new form and with this code alone.. and try pressing the tab key.. coz it works to me
    ____________

    Private Sub Form_KeyPress(KeyAscii As Integer)
    MsgBox KeyAscii
    End Sub
    ____________


    Tab Key = 9 in ascii

    or try this one... para testing lang.
    ========
    Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 9 Then
    MsgBox "tab key"
    End If
    End Sub
    ========

    and also
    vbkeytab
    vbkeyA
    etc.. are just used in _KeyDown and _KeyUp subs

  8. #8

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    To: nunobone
    K. Thanks a lot 4 your help bay ha!
    I'll keep that in my notes for future needs. I already find a way to lock the tab key by disabling the Tab Stop to all objects when editing or adding new in a record. Pero i'll try your advice karon bay if unsa. I bet that is more credible gyud. Again thanks bay ha!
    Sorry diay pud sa ako previous post. Wala lang gyud ko ka bantay. Na tay-an na lagi ko sa VB 6. Hehe... Hope all you guys can help me from time to time.


    See Yah!
    4u

  9. #9

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    Quote Originally Posted by 4U
    ================================================== =
    Private Sub Text1_KeyPress(KeyAscii As Integer)

    If KeyAscii = vbKeyTab Then
    If Text1 = Null Then
    Text1.SetFocus
    Else
    KeyAscii = vbKeyTab
    End If
    End If

    End Sub
    ================================================== =
    first, vbKeyTab and vbTab are two different things.

    second, use the pre-defined function Asc(<character>) to get the ASCII value of a character.

    nunobone is right, Tab's ASCII value is 9, that is for vbTab and not for vbKeyTab. fyi, vbkeytab's ASCII value is 57.

    but then as mAlD|tO said, its not a good programming practice to have magic numbers on your code.

    try this one. it works 100%

    ================================================== =
    Private Sub Text1_KeyPress(KeyAscii As Integer)

    If KeyAscii = Asc(vbTab) Then
    MsgBox "Hello Garci, will I steal lead by more than 1M?"
    End If
    KeyAscii = vbTab
    End Sub
    ================================================== =

    ^^^ remember that it only works if there's no other object on the form.


    i guess, you are trapping blank textboxes, and you would like users to input data into the textbox first before going to the other textboxes.

    though its a good trapping technique but i suggest you should put the error trapping with empty textboxes on the edit/save/update button.


    in this way you dont have to worry blocking the tab key or changing the textboxes' properties.


    ===========================================

    Private Sub cmdSave_Click()

    If Text1.Text = "" Then
    MsgBox "enter data on text1"
    Text1.SetFocus
    Exit Sub
    End If

    If Text2.Text = "" Then
    MsgBox "enter data on text2"
    Text2.SetFocus
    Exit Sub
    End If


    'if all textboxes has been filled then

    saveData

    End Sub

    ===============================================

    in the above code, if the sub routine encounters a blank textbox, it will immediately ends the sub routine and focuses on the blank textbox. it wont update or save unless all textboxes has been filled.

    what if ang user dili mo-gamit ug Tab Key, mouse-oriented siya? so the above code still works.

  10. #10

    Default Re: VB Debugging Brain Freeze!... HELP ASAP!

    Quote Originally Posted by Seducer
    4U...
    this is not acceptable :
    If Text1 = Null Then
    try to change :
    if len(text1.text)=0 then
    hopes it works
    i think he means the first if block statement.
    the one your refering is the second one.

    and to answer your question..
    i agree with khyle_nexus.
    just my two cents.

  11.    Advertisement

Page 1 of 3 123 LastLast

Similar Threads

 
  1. CEBU as a country, share ur opinions and point of views...
    By bongjo in forum Politics & Current Events
    Replies: 18
    Last Post: 04-10-2009, 04:28 AM
  2. kinsay naa spitz pups dre? share ur exp with them beh...
    By baby_jenie in forum Pet Discussions
    Replies: 1
    Last Post: 05-21-2008, 05:36 PM
  3. Share ur Barbeque Sauce Kanang pinaka the best
    By skop in forum Food & Dining
    Replies: 5
    Last Post: 01-07-2008, 03:35 AM
  4. share ur problems... n70.. tabangay ta :)
    By sheka in forum Gizmos & Gadgets (Old)
    Replies: 19
    Last Post: 01-30-2007, 11:45 AM
  5. Replies: 1
    Last Post: 07-23-2006, 01:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top