|
-
Oct 1st, 2009, 07:40 AM
#1
Thread Starter
Lively Member
Recurring Random Countdown
Hello all,
My program is supposed to have a recurring random countdown. That each time it loops, it should have a new random time to countdown from.
Please look at my code and see what's wrong. I have tried several different ways, and nothing seems to work.
Thank you in advance.
Code:
Public Class MainPanel
Public Structure intimacyPlayer
Dim Name As String
Dim Age As Integer
Dim Gender As String
Dim attribute 1 As String
Dim attribute 2 As String
Dim attribute 3 As String
Dim attribute 4 As String
Dim attribute 5 As String
Dim attribute 6 As String
Dim attribute 7 As String
Dim attribute 8 As String
End Structure
Public Structure intimacyPreference
Dim KeepSettings As String
Dim Player1 As String
Dim Player2 As String
Dim Player3 As String
Dim Player4 As String
Dim Player5 As String
Dim Player6 As String
Dim Player7 As String
Dim Player8 As String
Dim Player9 As String
Dim Player10 As String
Dim Player11 As String
Dim Player12 As String
Dim Player13 As String
Dim Player14 As String
Dim Level As String
Dim Voice As String
Dim Volume As Integer
Dim Background As String
Dim myFont As String
Dim Objects As String
Dim Things As String
Dim Stuff As String
End Structure
Public myPlayers As New Collection
Dim spkr As New SpeechLib.SpVoice
Dim Min, Max As New Integer
Dim r As New Random
Dim CountDownTo As Integer = r.Next(10, 20)
Dim ts As New TimeSpan(0, 0, (CountDownTo))
Dim CountDown As New Stopwatch
Dim split As String()
Dim I As New Integer()
Dim pfl As New Integer()
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'***MAKE SURE WE HAVE INFO TO USE***
If System.IO.File.Exists(Application.StartupPath & "\Players.sex") = False Or System.IO.File.Exists(Application.StartupPath & "\preferences.sex") = False Then
Dim myControlPanel As New ControlPanel
myControlPanel.ShowDialog()
End If
'***CHECK IF 'KEEPSETTINGS' IS CHECKED*** (The users may want different options everytime.)
Dim strinput As String = ""
FileOpen(1, Application.StartupPath & "\preferences.sex", OpenMode.Input)
Do Until strinput.StartsWith("Keep")
Input(1, strinput)
If strinput = "KeepSettings = 0" Then
Reset()
Dim myControlPanel As New ControlPanel
myControlPanel.ShowDialog()
End If
Loop
FileClose(1)
'***SHOW SPLASHSCREEN2****
'***GET MIN AND MAX***
Timer1.Interval = 100
Timer1.Start()
CountDown.Reset() : CountDown.Start()
End Sub
Private Sub controlpanelbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles controlpanelbutton.Click
Reset()
CountDown.Stop()
Dim myControlPanel As New ControlPanel
Dim result As DialogResult 'so we know what they chose
result = myControlPanel.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
Else
End
End If
CountDown.Start()
End Sub
Private Sub PauseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PauseButton.Click
CountDown.Stop()
MsgBox("Click Ok to continue", MsgBoxStyle.ApplicationModal, "PAUSED")
CountDown.Start()
End Sub
Private Sub QuitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitButton.Click
Me.Close()
End
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim DurHold As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\preferences.sex")
Dim DurDelimiters() As String = {vbNewLine}
Dim DurTextLines() As String = DurHold.Split(DurDelimiters, StringSplitOptions.RemoveEmptyEntries)
pfl = DurTextLines.Length
For I = 1 To pfl
If DurTextLines(I).StartsWith("Minimum") Then
split = DurTextLines(I).Split("=")
Min = Trim(split(1))
Exit For
End If
Next
For I = 1 To pfl
If DurTextLines(I).StartsWith("Maximum") Then
split = DurTextLines(I).Split("=")
Max = Trim(split(1))
Exit For
End If
Next
'CountDownTo = r.Next(Min, Max)
FileOpen(1, Application.StartupPath & "\test1.txt", OpenMode.Append)
WriteLine(1, Min, Max, CountDownTo)
Reset()
If CountDown.IsRunning Then 'is the stopwatch running
If CountDown.Elapsed.TotalSeconds >= CountDownTo Then 'have we reached zero
'yes, stop the stopwatch
CountDown.Stop()
'***RANDOMLY SELECT TWO PLAYERS***
Dim I, pfl As New Integer()
Dim split As String()
Dim Doer As String = ""
Dim Receiver As String = ""
Dim pick As Integer
Dim rand As New Random
Dim sHold As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\preferences.sex")
Dim profileHold As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\Players.sex")
Dim sDelimiters() As String = {vbNewLine}
Dim sTextLines() As String = sHold.Split(sDelimiters, StringSplitOptions.RemoveEmptyEntries)
Dim profileDelimiters() As String = {vbNewLine}
Dim profileTextLines() As String = profileHold.Split(profileDelimiters, StringSplitOptions.RemoveEmptyEntries)
RepickDoer:
'***PICK NAMES***
Do
pick = rand.Next(1, 15)
For I = 1 To pick
If sTextLines(pick).StartsWith("Play") Then
split = sTextLines(pick).Split("=")
Doer = Trim(split(1))
End If
Next
Loop While Doer = ""
Dim D_Name As String = ""
pfl = profileTextLines.Length
For I = 1 To pfl
If profileTextLines(I).StartsWith("Name") Then
split = profileTextLines(I).Split("=")
D_Name = Trim(split(1))
If D_Name = Doer Then
Exit For
End If
End If
Next
Dim D_Age As New Integer
split = profileTextLines(I + 1).Split("=")
D_Age = Trim(split(1))
If D_Age < 18 Then
GoTo RepickDoer
End If
'Get Profile info
RepickReceiver:
Do
pick = rand.Next(1, 15)
For I = 1 To pick
If sTextLines(pick).StartsWith("Play") Then
split = sTextLines(pick).Split("=")
Receiver = Trim(split(1))
End If
Next
Loop While Receiver = "" Or Receiver = Doer
Dim R_Name As String = ""
pfl = profileTextLines.Length
For I = 1 To pfl
If profileTextLines(I).StartsWith("Name") Then
split = profileTextLines(I).Split("=")
R_Name = Trim(split(1))
If R_Name = Receiver Then
Exit For
End If
End If
Next
'Get Profile Info...
'***FILTER PROFILE INFO***
'***FORMAT SENTENCE***
'Write it
Label1.Text = Sentence
spkr = New SpeechLib.SpVoice
spkr.Speak(Label1.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
CountDown.Reset() : CountDown.Start()
Else
Label2.Text = ts.Subtract(CountDown.Elapsed).ToString.Substring(0, 8) 'show time remaining
End If
End If
End Sub
End Class
A large portion of this code has been omitted to protect the innocent.
Anyone who does not wonder, is either omnipotent or a fool.
Amerigoware <<<My Projects
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|