在vb.net中移动pictuerbox或图像 [英] moving pictuerbox or image in vb.net

查看:81
本文介绍了在vb.net中移动pictuerbox或图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 在我的表格上有2个文本框(用户名和密码)和汽车图像
如果用户输入正确的用户名和密码并按登录按钮,则汽车将从左向右移动(如进度条移动),然后将打开另一种形式,如何使用vb.net来使汽车移动?

我尝试了此代码,但是它是错误的:

 私有  Sub  Timer1_Tick( ByVal 发​​件人 As 系统.对象 ByVal  e  As  System.EventArgs)句柄 Timer1.Tick

        静态 x  As  整数 =  5 
        静态 y  As  整数 =  0 
        静态翻转 As  整数 = 错误

        如果 Mod   2  =  0  然后
             .PictureBox1.Image = My.Resources.ferrari_icon
        其他
             .PictureBox1.Image = My.Resources.ferrari_icon

        结束 如果
        如果  .PictureBox1.Left> =  500  然后
            x = -5
            翻转= 正确
         ElseIf   .PictureBox1.Left> =  0  然后
            x =  5 
            翻转= 错误
        结束 如果
        如果 Flip = 正确 然后
             .PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)

        结束 如果
         .PictureBox1.Left =  .PictureBox1.Left + x
        y + =  1 

    结束  

解决方案

这是怎么回事?您可能要做的就是在代码末尾刷新图片框.


hi on my form there is 2 text box (username and password) and image of car
if the user enter correct user name and password and press on login button the car will move from left to right (like the progressbar movement ) then another form will open how can i make the car move using vb.net?

i try this code but its wrong:

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

        Static x As Integer = 5
        Static y As Integer = 0
        Static Flip As Integer = False

        If y Mod 2 = 0 Then
            Me.PictureBox1.Image = My.Resources.ferrari_icon
        Else
            Me.PictureBox1.Image = My.Resources.ferrari_icon

        End If
        If Me.PictureBox1.Left >= 500 Then
            x = -5
            Flip = True
        ElseIf Me.PictureBox1.Left >= 0 Then
            x = 5
            Flip = False
        End If
        If Flip = True Then
            Me.PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)

        End If
        Me.PictureBox1.Left = Me.PictureBox1.Left + x
        y += 1

    End Sub

解决方案

In what way is it wrong? It could be that all you need to do is refresh the picturebox at the end of the code.


这篇关于在vb.net中移动pictuerbox或图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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