VBでストループカラーワードテストを作成したいです.
上に問題(例:「あか」という文字が青色で書かれている)下に答え(例:あか)
上と問題に対して下の答えがあっていれば右クリック,間違っていれば左クリックを押します.右もしくは左クリックされるか,問題が表示されてから2秒立つか,すると次の問題と答えが表示されるというものを作ろうとしています.
現在,問題をランダムな文字と色の組み合わせで表示させること,下の答えをランダムな文字で表示させること,これらの文字を2秒毎に表示させることが下記のコードでできています.
問題開始から5分後に色を4色にするために新しいフォームを表示させたいのですが,うまくいきません.
アドバイスをお願いします.
以下コードです.
Public Class Form1
Private Sub colorword1() Dim a() As String = New String() {"あか", "あお", "みどり"} Randomize() Label1.Text = a(Math.Floor(3 * Rnd())) RichTextBox1.Text = a(Math.Floor(3 * Rnd())) RichTextBox1.SelectionAlignment = HorizontalAlignment.Center End Sub Private Sub colorword2() Dim rnd As New System.Random() ' 0 以上 2 未満の乱数を取得する(0,1,2がランダムに判定される) Dim iResult As Integer = rnd.Next(3) If iResult = 0 Then RichTextBox1.ForeColor = Color.Red '0の時は赤 ElseIf iResult = 1 Then RichTextBox1.ForeColor = Color.Blue '1の時は青 ElseIf iResult = 2 Then RichTextBox1.ForeColor = Color.Green '2の時は緑 End If End Sub Private Sub Form1_Activated(sender As Object, e As EventArgs) Handles Me.Activated Me.Timer1.Interval = 1000 * 4 Me.Timer1.Start() Me.Timer2.Interval = 1000 * 60 * 5 Me.Timer2.Start() End Sub Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Call colorword1() Call colorword2() End Sub Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick Me.Close() Form2.Show() End Sub Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick Select Case e.Button Case Windows.Forms.MouseButtons.Left Me.Timer1.Stop() Call colorword1() Call colorword2() Me.Timer1.Interval = 4000 Me.Timer1.Start() Case Windows.Forms.MouseButtons.Right Me.Timer1.Stop() Call colorword1() Call colorword2() Me.Timer1.Interval = 4000 Me.Timer1.Start() End Select End Sub Private Function RGB(p1 As Integer) As Color Throw New NotImplementedException End Function Private Function RGB(p1 As Integer, p2 As Integer, p3 As Integer) As Color Throw New NotImplementedException End Function
End Class
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/18 07:54
2016/01/18 07:55