简体   繁体   English

文本向上滚动,但在关闭表单后。 文本不会重新开始。 vb.net

[英]Text scrolling up, but after closing the form. The text wont back on the start. vb.net

I was able to scroll the text up, put a stop on it when it reached a certain location on Y. 我可以向上滚动文本,当文本到达Y上的某个位置时停下来。

However, when I was trying to load the credit form again. 但是,当我尝试再次加载信用表时。 It will not be back on the start. 它不会重新开始。

Here's the code I'm working on. 这是我正在处理的代码。

    Public Class creditsform
    Private Sub creditsform_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed

        Label1.Location = New Point(Label1.Location.X, Label1.Location.Y = 304)  ' put back the label where it is.


    End Sub

    Private Sub creditsform_Load(sender As Object, e As EventArgs) Handles Me.Load

        Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Label1.Location = New Point(Label1.Location.X, Label1.Location.Y - 5) ' scroll up the label up 
        If (Label1.Location.Y = -1506) Then ' closes the form if he reach the end of credit roll
            Timer1.Enabled = False ' disable the timer
            Me.Close() ' then close the form

        End If
    End Sub
End Class

EDIT: HERE IS THE FIRST LOAD AND THE SECOND LOAD OF THE FORM. 编辑:这是表格的第一负荷和第二负荷。 Also after the 2nd load, it doesn't execute the if else statement to close automatically the form. 同样在第二次加载后,它不会执行if else语句来自动关闭表单。

1ST LOAD & 2ND LOAD 1st负载和2nd负载

Here's where creditsform called. 这是creditsform调用的地方。

Public Class EndGame


Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Dim Red, Green, Blue As Integer
    Dim RandomNumGenerator As New Random
    Red = RandomNumGenerator.Next(0, 255)
    Green = RandomNumGenerator.Next(0, 255)
    Blue = RandomNumGenerator.Next(0, 255)
    Me.Label4.ForeColor = Color.FromArgb(Red, Green, Blue)
    Me.Label5.ForeColor = Color.FromArgb(Red, Green, Blue)
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '' this button closes the form and shows the creditsform
    Me.Close()
    creditsform.ShowDialog()

End Sub
End class

If I understood the problem correctly since it's not very clear what you are trying to do. 如果我对问题的理解不正确,因为您不清楚要做什么。

This is normal your using a class but not creating new instance of it so your variables don't reset. 使用类但不创建类的新实例是正常的,因此不会重置变量。 you should try this: 您应该尝试这样:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '' this button closes the form and shows the creditsform
    Me.Close()
    Dim MyCredits As New creditsform
    MyCredits.ShowDialog()
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM