2017-05-22 4 views
0

私はテキストをスクロールして、Yの特定の場所に達したときに停止しました。テキストをスクロールアップしますが、フォームを閉じると終了します。テキストは最初に戻らない。 vb.net

ただし、クレジットフォームを再度読み込もうとしていました。それは最初に戻ってくることはありません。

私が取り組んでいるコードは次のとおりです。

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 

編集:ここには、最初の読み込みと2番目の読み込みがあります。 また、2回目のロード後、フォームを自動的に閉じるためにif else文を実行しません。

1ST LOAD & 2ND LOAD

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 

答えて

0

私が問題を正しく理解していれば、あなたがしようとしていることがあまり明確ではないからです。

これは通常、クラスを使用していますが、新しいインスタンスを作成していないため、変数がリセットされません。これを試してください:

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 
+0

私にこれに関する知識を与えてくれてありがとう。はい、それは働いた。私は本当にそれを感謝します! – Ray

関連する問題