Results 1 to 11 of 11

Thread: [RESOLVED]moving error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Resolved [RESOLVED]moving error

    VB Code:
    1. Private Sub cmdmmove_KeyPress(KeyAscii As Integer)
    2.         If KeyAscii = 97 And picleftmale.Visible = True Then
    3.         frmupchar.Left = frmupchar.Left - 100
    4.         picleftmale.Visible = True
    5.         picbackmale.Visible = False
    6.         picfrontmale.Visible = False
    7.     ElseIf KeyAscii = 115 And picleftmale.Visible = True Then
    8.         frmupchar.Top = frmupchar.Top + 100
    9.         picfrontmale.Visible = True
    10.         picleftmale.Visible = False
    11.         picbackmale.Visible = False
    12.     ElseIf KeyAscii = 100 And picleftmale.Visible = True Then
    13.         frmupchar.Left = frmupchar.Left + 100
    14.     ElseIf KeyAscii = 119 And picleftmale.Visible = True Then
    15.         frmupchar.Top = frmupchar.Top - 100
    16.         picbackmale.Visible = True
    17.         picleftmale.Visible = False
    18.         picfrontmale.Visible = False
    19.     End If
    that code is to make the frm move but the problem is it doesnt want to move anymore. maybe its bacause i have a **** load of stuff on the form. im not sure but ill leave the form so u can take a look
    Last edited by Ebiru; Apr 10th, 2006 at 05:42 PM.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: moving error

    my guess w/o downloading...

    that cmdmmove needs to have the focus...

    after downloading.. I have no clue whats going on in that form!! lol

    try:
    change the forms KeyPreview to True
    then move your keypress code to Form_Keypress
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: moving error

    Quote Originally Posted by Static
    my guess w/o downloading...

    that cmdmmove needs to have the focus...

    after downloading.. I have no clue whats going on in that form!! lol

    try:
    change the forms KeyPreview to True
    then move your keypress code to Form_Keypress
    well u need to click cmdmmove other wise u wont move cause i got 3 other cmds which get the focus n it saved me some time and i try with the form_keypress but u need focus but the cmds got it

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: moving error

    but the problem is stuff is appearing , disapearing etc.. U might want to start over..
    make your object move properly.. then slowly add things back in...


    if u set keypreview to true.. it will still catch the keypress event even if a cmdbutton or textbox etc has focus...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: moving error

    Quote Originally Posted by Ebiru
    VB Code:
    1. Private Sub cmdmmove_KeyPress(KeyAscii As Integer)
    2.         If KeyAscii = 97 And picleftmale.Visible = True Then
    3.         frmupchar.Left = frmupchar.Left - 100
    4.         picleftmale.Visible = True
    5.         picbackmale.Visible = False
    6.         picfrontmale.Visible = False
    7.     ElseIf KeyAscii = 115 And picleftmale.Visible = True Then
    8.         frmupchar.Top = frmupchar.Top + 100
    9.         picfrontmale.Visible = True
    10.         picleftmale.Visible = False
    11.         picbackmale.Visible = False
    12.     ElseIf KeyAscii = 100 And picleftmale.Visible = True Then
    13.         frmupchar.Left = frmupchar.Left + 100
    14.     ElseIf KeyAscii = 119 And picleftmale.Visible = True Then
    15.         frmupchar.Top = frmupchar.Top - 100
    16.         picbackmale.Visible = True
    17.         picleftmale.Visible = False
    18.         picfrontmale.Visible = False
    19.     End If
    that code is to make the frm move but the problem is it doesnt want to move anymore. maybe its bacause i have a **** load of stuff on the form. im not sure but ill leave the form so u can take a look
    That would be better written like

    VB Code:
    1. If picleftmale.Visible = True Then
    2.         Select Case KeyAscii
    3.             Case 97
    4.                 frmupchar.Left = frmupchar.Left - 100
    5.                 picleftmale.Visible = True
    6.                 picbackmale.Visible = False
    7.                 picfrontmale.Visible = False
    8.             Case 115
    9.                 frmupchar.Top = frmupchar.Top + 100
    10.                 picfrontmale.Visible = True
    11.                 picleftmale.Visible = False
    12.                 picbackmale.Visible = False
    13.             Case 100
    14.                 frmupchar.Left = frmupchar.Left + 100
    15.             Case 119
    16.                 frmupchar.Top = frmupchar.Top - 100
    17.                 picbackmale.Visible = True
    18.                 picleftmale.Visible = False
    19.                 picfrontmale.Visible = False
    20.         End Select
    21.     End If

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: moving error

    Quote Originally Posted by MartinLiss
    That would be better written like

    VB Code:
    1. If picleftmale.Visible = True Then
    2.         Select Case KeyAscii
    3.             Case 97
    4.                 frmupchar.Left = frmupchar.Left - 100
    5.                 picleftmale.Visible = True
    6.                 picbackmale.Visible = False
    7.                 picfrontmale.Visible = False
    8.             Case 115
    9.                 frmupchar.Top = frmupchar.Top + 100
    10.                 picfrontmale.Visible = True
    11.                 picleftmale.Visible = False
    12.                 picbackmale.Visible = False
    13.             Case 100
    14.                 frmupchar.Left = frmupchar.Left + 100
    15.             Case 119
    16.                 frmupchar.Top = frmupchar.Top - 100
    17.                 picbackmale.Visible = True
    18.                 picleftmale.Visible = False
    19.                 picfrontmale.Visible = False
    20.         End Select
    21.     End If
    ty for cleaning up my code but it still doesnt work

  7. #7
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: moving error

    question - When you "hold" the key down does it work?
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  8. #8

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: moving error

    Quote Originally Posted by damasterjo
    question - When you "hold" the key down does it work?
    no
    Quote Originally Posted by MartinLiss
    Put a breakpoint on the If picleftmale.Visible = True Then line and then step through the code using F8.
    im not getting what u mean

  10. #10
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: moving error

    a breakpoint is when u click in the column next to the line of code. it will place a red dot in the column and highlight the line red... then when you run the code it willstop at that line. at this point u can pres F8 and have the code execute one line at a time.. helps to figure out where the problem is
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: moving error

    i figure it out....
    VB Code:
    1. If picleftmale.Visible = True Then
    that is what was wrong.... ty for ur help guys

Posting Permissions

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



Click Here to Expand Forum to Full Width