- #1
phion
Gold Member
- 175
- 39
Hi,
I've written some code in VB6, and I'm trying to figure out how to add color to individual words and numbers.
The program is a console application Roulette game. What I need to figure out is how to make my money green if positive and red if negative, and color the words "red" and "black" as they appear in the display. Any help is much appreciated. I'm a beginner.
I've written some code in VB6, and I'm trying to figure out how to add color to individual words and numbers.
The program is a console application Roulette game. What I need to figure out is how to make my money green if positive and red if negative, and color the words "red" and "black" as they appear in the display. Any help is much appreciated. I'm a beginner.
Code:
Module Roulette
Sub Main()
Dim choice, pick As Integer
Dim bank, bet, outcome, winnings, payout As Double
Dim random As New Random
bank = 100
Console.WriteLine("Welcome to our casino!")
Console.WriteLine("We only have Roulette, I hope that's alright.")
Console.WriteLine("I am starting you out with " & bank.ToString("C") & ", so go nuts!")
Console.WriteLine()
Do
outcome = random.Next(0, 37)
menu(bank)
Console.Write("Please enter your choice: ")
choice = Console.ReadLine()
If choice = 7 Then
Environment.Exit(7)
End If
If choice = 6 Then
Do
Console.Write("Pick a number: ")
pick = Console.ReadLine()
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
If pick = outcome And outcome Mod 2 = 0 Then
winnings = True
payout = 35 * bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You win " & payout.ToString("C") & "!")
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf pick = outcome And outcome Mod 2 <> 0 Then
winnings = True
payout = 35 * bet
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf pick <> outcome And outcome Mod 2 = 0 Then
winnings = False
payout = bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf pick <> outcome And outcome Mod 2 <> 0 Then
winnings = False
payout = bet
Console.WriteLine(outcome & " Black")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
End If
Exit Do
Loop
End If If choice = 1 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 1 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Black")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 2 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 2 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet
Console.WriteLine(outcome & " Black")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 3 And outcome <= 12 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet * 2
Console.WriteLine(outcome & " Red")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 3 And outcome <= 12 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet * 2
Console.WriteLine(outcome & " Black")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 3 And outcome > 12 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 3 And outcome > 12 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Black")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 4 And outcome > 12 And outcome <= 24 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet * 2
Console.WriteLine(outcome & " Red")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 4 And outcome > 12 And outcome <= 24 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet * 2
Console.WriteLine(outcome & " Black")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 4 And outcome < 12 Or outcome > 24 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 4 And outcome < 12 Or outcome > 24 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Black")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 5 And outcome > 24 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet * 2
Console.WriteLine(outcome & " Red")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 5 And outcome > 24 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = True
payout = bet * 2
Console.WriteLine(outcome & " Black")
Console.WriteLine("You win " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 5 And outcome < 24 And outcome Mod 2 = 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Red")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
ElseIf choice = 5 And outcome < 24 And outcome Mod 2 <> 0 Then
Console.Write("Place your bet: ")
bet = Console.ReadLine()
Console.WriteLine("Press any key to spin the wheel...")
Console.ReadKey(True)
winnings = False
payout = bet
Console.WriteLine(outcome & " Black")
Console.WriteLine("You lose " & payout.ToString("C"))
Console.WriteLine("Press any key to play again...")
Console.ReadKey(True)
Console.Clear()
End If
If winnings = True Then
bank += payout
Else bank -= payout
End If
Loop
End Sub
Sub menu(ByRef bank As Double)
Console.WriteLine("Place your bet (" & bank.ToString("C") & ")")
Console.WriteLine("1. Bet on red (pays 1:1)")
Console.WriteLine("2. Bet on black (pays 1:1)")
Console.WriteLine("3. First 12 (pays 2:1)")
Console.WriteLine("4. Middle 12 (pays 2:1)")
Console.WriteLine("5. Last 12 (pays 2:1)")
Console.WriteLine("6. Choose anyone number (pays 35:1)")
Console.WriteLine("7. Cash out")
Console.WriteLine("====================================")
End Sub
End Module