我应该在哪里放置这段代码 [英] where should i put this code

查看:79
本文介绍了我应该在哪里放置这段代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vb.net,当用户输入正确的名称和密码后,在我的表单上有picuterbox(汽车),然后按登录按钮,汽车将从(向左书写)移动,但我不知道我应该放在哪里运动代码???我把它放在表格的计时器上,当我打开表格时,汽车直接移动. 我想要(登录按钮)上的移动代码(如果username& password = correct)如何????????????????????????????

我刚刚用以下代码制作了一个计时器:

I am using vb.net and on my form there is picuterbox (car) when user insert the correct name and password then press on login button the car will move from (left to write) but i dont know where i should put the code of movement??? i had put it on the timer of the form and when i open the form the car move directly..
i want the code of movement on the (login button)(if username&password=correct)how??????????????????????????

i had just make a timer with this code:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        PictureBox3.Left = PictureBox3.Left + 100

    End Sub



这是登录名的验证:



and this is the validition of the login:

Private Sub Piclog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Piclog.Click
      Try

          If txtname.Text.Trim() = "" Or txtpass.Text.Trim() = "" Then

              My.Computer.Audio.Play(My.Resources.Windows_Error, AudioPlayMode.Background)
              MessageBox.Show("Invalid Username or Password")

              Exit Sub


          End If



          If Combolevel.Text = "" Then
              MessageBox.Show("You should select your level")
          End If


      Catch ex As Exception

          MessageBox.Show(ex.Message)


          Me.Hide()


      End Try




      Select Case Combolevel.SelectedIndex



          Case 0

              My.Computer.Audio.Play(My.Resources.ss, AudioPlayMode.Background)

              loading.Show()

          Case 1

              My.Computer.Audio.Play(My.Resources.ss, AudioPlayMode.Background)

              Loading2.Show()

      End Select




  End Sub

推荐答案

请确保您的计时器已禁用,然后在用户输入正确的密码时启用它.
make sure that your timer is disabled and then enable it when the user enters the correct password.


这篇关于我应该在哪里放置这段代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆