SIMULAZIONE ROULETTE
Public Class Form1
Dim SpinAnswer As Integer
Dim rand As New Random
Private Sub Button38_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button38.Click
Dim SpinAnswer As Integer
Dim rand As New Random
SpinAnswer = rand.Next(0, 36)
Button39.Text = SpinAnswer
ListBox1.Items.Add(Button39.Text)
If Button39.Text = "1" Then
Button40.Text = "ROSSO"
Button1.BackColor = Color.Yellow
ElseIf Button39.Text = "2" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "3" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "4" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "5" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "6" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "7" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "8" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "9" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "10" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "11" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "12" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "13" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "14" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "15" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "16" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "17" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "18" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "19" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "20" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "21" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "22" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "23" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "24" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "25" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "26" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "27" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "28" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "29" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "30" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "31" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "32" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "33" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "34" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "35" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "36" Then
Button1.BackColor = Color.Red
ElseIf Button39.Text = "0" Then
Button1.BackColor = Color.Red
End If
If Button39.Text = "2" Then
Button40.Text = "NERO"
Button2.BackColor = Color.Yellow
ElseIf Button39.Text = "1" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "3" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "4" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "5" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "6" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "7" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "8" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "9" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "10" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "11" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "12" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "13" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "14" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "15" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "16" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "17" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "18" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "19" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "20" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "21" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "22" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "23" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "24" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "25" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "26" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "27" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "28" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "29" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "30" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "31" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "32" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "33" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "34" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "35" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "36" Then
Button2.BackColor = Color.DarkGray
ElseIf Button39.Text = "0" Then
Button2.BackColor = Color.DarkGray
End If
If Button39.Text = "3" Then
Button40.Text = "ROSSO"
Button3.BackColor = Color.Yellow
ElseIf Button39.Text = "1" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "2" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "4" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "5" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "6" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "7" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "8" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "9" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "10" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "11" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "12" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "13" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "14" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "15" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "16" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "17" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "18" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "19" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "20" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "21" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "22" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "23" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "24" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "25" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "26" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "27" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "28" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "29" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "30" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "31" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "32" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "33" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "34" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "35" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "36" Then
Button3.BackColor = Color.Red
ElseIf Button39.Text = "0" Then
Button3.BackColor = Color.Red
End If
If Button39.Text = "4" Then
Button40.Text = "NERO"
Button4.BackColor = Color.Yellow
ElseIf Button39.Text = "1" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "2" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "3" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "4" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "5" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "6" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "7" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "8" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "9" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "10" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "11" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "12" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "13" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "14" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "15" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "16" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "17" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "18" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "19" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "20" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "21" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "22" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "23" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "24" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "25" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "26" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "27" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "28" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "29" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "30" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "31" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "32" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "33" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "34" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "35" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "36" Then
Button4.BackColor = Color.DarkGray
ElseIf Button39.Text = "0" Then
Button4.BackColor = Color.DarkGray
End If
If Button39.Text = "5" Then
Button40.Text = "ROSSO"
Button5.BackColor = Color.Yellow
Else
Button5.BackColor = Color.Red
End If
If Button39.Text = "6" Then
Button40.Text = "NERO"
Button6.BackColor = Color.Yellow
Else
Button6.BackColor = Color.DarkGray
End If
If Button39.Text = "7" Then
Button40.Text = "ROSSO"
Button7.BackColor = Color.Yellow
Else
Button7.BackColor = Color.Red
End If
If Button39.Text = "8" Then
Button40.Text = "NERO"
Button8.BackColor = Color.Yellow
Else
Button8.BackColor = Color.DarkGray
End If
If Button39.Text = "9" Then
Button40.Text = "ROSSO"
Button9.BackColor = Color.Yellow
Else
Button9.BackColor = Color.Red
End If
If Button39.Text = "10" Then
Button40.Text = "NERO"
Button10.BackColor = Color.Yellow
Else
Button10.BackColor = Color.DarkGray
End If
If Button39.Text = "11" Then
Button40.Text = "NERO"
Button11.BackColor = Color.Yellow
Else
Button11.BackColor = Color.DarkGray
End If
If Button39.Text = "12" Then
Button40.Text = "ROSSO"
Button12.BackColor = Color.Yellow
Else
Button12.BackColor = Color.Red
End If
If Button39.Text = "13" Then
Button40.Text = "NERO"
Button13.BackColor = Color.Yellow
Else
Button13.BackColor = Color.DarkGray
End If
If Button39.Text = "14" Then
Button40.Text = "ROSSO"
Button14.BackColor = Color.Yellow
Else
Button14.BackColor = Color.Red
End If
If Button39.Text = "15" Then
Button40.Text = "NERO"
Button15.BackColor = Color.Yellow
Else
Button15.BackColor = Color.DarkGray
End If
If Button39.Text = "16" Then
Button40.Text = "ROSSO"
Button16.BackColor = Color.Yellow
Else
Button16.BackColor = Color.Red
End If
If Button39.Text = "17" Then
Button40.Text = "NERO"
Button17.BackColor = Color.Yellow
Else
Button17.BackColor = Color.DarkGray
End If
If Button39.Text = "18" Then
Button40.Text = "ROSSO"
Button18.BackColor = Color.Yellow
Else
Button18.BackColor = Color.Red
End If
If Button39.Text = "19" Then
Button40.Text = "ROSSO"
Button19.BackColor = Color.Yellow
Else
Button19.BackColor = Color.Red
End If
If Button39.Text = "20" Then
Button40.Text = "NERO"
Button20.BackColor = Color.Yellow
Else
Button20.BackColor = Color.DarkGray
End If
If Button39.Text = "21" Then
Button40.Text = "ROSSO"
Button21.BackColor = Color.Yellow
Else
Button21.BackColor = Color.Red
End If
If Button39.Text = "22" Then
Button40.Text = "NERO"
Button22.BackColor = Color.Yellow
Else
Button22.BackColor = Color.DarkGray
End If
If Button39.Text = "23" Then
Button40.Text = "ROSSO"
Button23.BackColor = Color.Yellow
Else
Button23.BackColor = Color.Red
End If
If Button39.Text = "24" Then
Button40.Text = "NERO"
Button24.BackColor = Color.Yellow
Else
Button24.BackColor = Color.DarkGray
End If
If Button39.Text = "25" Then
Button40.Text = "ROSSO"
Button25.BackColor = Color.Yellow
Else
Button25.BackColor = Color.Red
End If
If Button39.Text = "26" Then
Button40.Text = "NERO"
Button26.BackColor = Color.Yellow
Else
Button26.BackColor = Color.DarkGray
End If
If Button39.Text = "27" Then
Button40.Text = "ROSSO"
Button27.BackColor = Color.Yellow
Else
Button27.BackColor = Color.Red
End If
If Button39.Text = "28" Then
Button40.Text = "NERO"
Button28.BackColor = Color.Yellow
Else
Button28.BackColor = Color.DarkGray
End If
If Button39.Text = "29" Then
Button40.Text = "NERO"
Button29.BackColor = Color.Yellow
Else
Button29.BackColor = Color.DarkGray
End If
If Button39.Text = "30" Then
Button40.Text = "ROSSO"
Button30.BackColor = Color.Yellow
Else
Button30.BackColor = Color.Red
End If
If Button39.Text = "31" Then
Button40.Text = "NERO"
Button31.BackColor = Color.Yellow
Else
Button31.BackColor = Color.DarkGray
End If
If Button39.Text = "32" Then
Button40.Text = "ROSSO"
Button32.BackColor = Color.Yellow
Else
Button32.BackColor = Color.Red
End If
If Button39.Text = "33" Then
Button40.Text = "NERO"
Button33.BackColor = Color.Yellow
Else
Button33.BackColor = Color.DarkGray
End If
If Button39.Text = "34" Then
Button40.Text = "ROSSO"
Button34.BackColor = Color.Yellow
Else
Button34.BackColor = Color.Red
End If
If Button39.Text = "35" Then
Button40.Text = "NERO"
Button35.BackColor = Color.Yellow
Else
Button35.BackColor = Color.DarkGray
End If
If Button39.Text = "36" Then
Button40.Text = "ROSSO"
Button36.BackColor = Color.Yellow
Else
Button36.BackColor = Color.Red
End If
If Button39.Text = "0" Then
Button40.Text = "VERDE"
Button37.BackColor = Color.Yellow
Else
Button37.BackColor = Color.Green
End If
If Button39.Text = "1" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "2" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "3" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "4" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "5" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "6" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "7" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "8" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "9" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "10" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "11" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "12" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "13" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "14" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "15" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "16" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "17" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "18" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "19" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "20" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "21" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "22" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "23" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "24" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "25" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "26" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "27" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "28" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "29" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "30" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "31" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "32" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "33" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "34" Then
Button41.Text = "COLONNA 1"
End If
If Button39.Text = "35" Then
Button41.Text = "COLONNA 2"
End If
If Button39.Text = "36" Then
Button41.Text = "COLONNA 3"
End If
If Button39.Text = "0" Then
Button41.Text = "ZERO"
End If
ListBox2.Items.Add(Button40.Text)
ListBox3.Items.Add(Button41.Text)
If TextBox1.Text = "2" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 4")
End If
End If
If TextBox1.Text = "4" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 8")
End If
End If
If TextBox1.Text = "8" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 16")
End If
End If
If TextBox1.Text = "16" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 32")
End If
End If
If TextBox1.Text = "32" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 64")
End If
End If
If TextBox1.Text = "64" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 128")
End If
End If
If TextBox1.Text = "128" Then
If Button40.Text = "ROSSO" Then
MsgBox("VINCITA 256")
End If
End If
If TextBox1.Text = "2" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "4" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "8" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "16" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "32" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "64" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "128" Then
If Button40.Text = "NERO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "2" Then
If Button40.Text = "NERO" Then
MsgBox("VINCITA 4")
End If
End If
If TextBox4.Text = "4" Then
If Button40.Text = "NERO" Then
MsgBox("VINCITA 8")
End If
End If
If TextBox4.Text = "16" Then
If Button40.Text = "NERO" Then
MsgBox("VINCITA 32")
End If
End If
If TextBox4.Text = "32" Then
If Button40.Text = "NERO" Then
MsgBox("VINCITA 64")
End If
End If
If TextBox4.Text = "64" Then
If Button40.Text = "NERO" Then
MsgBox("VINCITA 128")
End If
End If
If TextBox4.Text = "128" Then
If Button40.Text = "NERO" Then
MsgBox("VINCITA 256")
End If
End If
If TextBox4.Text = "2" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "4" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "8" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "16" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "32" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "64" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox4.Text = "128" Then
If Button40.Text = "ROSSO" Then
MsgBox("SCOMMESSA PERSA")
End If
End If
If TextBox1.Text = "2" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox1.Text = "4" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox1.Text = "8" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox1.Text = "16" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox1.Text = "32" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox1.Text = "64" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox1.Text = "128" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "2" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "4" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "8" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "16" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "32" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "64" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox4.Text = "128" Then
If Button40.Text = "VERDE" Then
MsgBox("TASSA SULLO ZERO")
End If
End If
If TextBox2.Text = "1" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 3")
End If
End If
If TextBox2.Text = "1" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 1")
End If
End If
If TextBox2.Text = "1" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 1")
End If
End If
If TextBox2.Text = "2" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 6")
End If
End If
If TextBox2.Text = "2" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 2")
End If
End If
If TextBox2.Text = "2" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 2")
End If
End If
If TextBox2.Text = "3" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 9")
End If
End If
If TextBox2.Text = "3" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 3")
End If
End If
If TextBox2.Text = "3" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 3")
End If
End If
If TextBox2.Text = "5" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 15")
End If
End If
If TextBox2.Text = "5" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 5")
End If
End If
If TextBox2.Text = "5" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 5")
End If
End If
If TextBox2.Text = "8" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 24")
End If
End If
If TextBox2.Text = "8" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 8")
End If
End If
If TextBox2.Text = "8" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 8")
End If
End If
If TextBox2.Text = "13" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 39")
End If
End If
If TextBox2.Text = "13" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 13")
End If
End If
If TextBox2.Text = "13" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 13")
End If
End If
If TextBox2.Text = "21" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 63")
End If
End If
If TextBox2.Text = "21" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 21")
End If
End If
If TextBox2.Text = "21" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 21")
End If
End If
If TextBox2.Text = "34" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 102")
End If
End If
If TextBox2.Text = "34" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 34")
End If
End If
If TextBox2.Text = "34" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 34")
End If
End If
If TextBox2.Text = "55" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 165")
End If
End If
If TextBox2.Text = "55" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 55")
End If
End If
If TextBox2.Text = "55" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 55")
End If
End If
If TextBox2.Text = "89" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 267")
End If
End If
If TextBox2.Text = "89" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 89")
End If
End If
If TextBox2.Text = "89" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 89")
End If
End If
If TextBox2.Text = "89" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("VINCITA 267")
End If
End If
If TextBox2.Text = "89" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 89")
End If
End If
If TextBox2.Text = "89" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 89")
End If
End If
If TextBox5.Text = "1" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 3")
End If
End If
If TextBox5.Text = "1" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 1")
End If
End If
If TextBox5.Text = "1" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 1")
End If
End If
If TextBox5.Text = "2" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 6")
End If
End If
If TextBox5.Text = "2" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 2")
End If
End If
If TextBox5.Text = "2" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 2")
End If
End If
If TextBox5.Text = "3" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 9")
End If
End If
If TextBox5.Text = "3" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 3")
End If
End If
If TextBox5.Text = "3" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 3")
End If
End If
If TextBox5.Text = "5" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 15")
End If
End If
If TextBox5.Text = "5" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 5")
End If
End If
If TextBox5.Text = "5" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 5")
End If
End If
If TextBox5.Text = "8" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 24")
End If
End If
If TextBox5.Text = "8" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 8")
End If
End If
If TextBox5.Text = "8" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 8")
End If
End If
If TextBox5.Text = "13" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 39")
End If
End If
If TextBox5.Text = "13" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 13")
End If
End If
If TextBox5.Text = "13" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 13")
End If
End If
If TextBox5.Text = "21" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 63")
End If
End If
If TextBox5.Text = "21" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 21")
End If
End If
If TextBox5.Text = "21" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 21")
End If
End If
If TextBox5.Text = "34" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 102")
End If
End If
If TextBox5.Text = "34" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 34")
End If
End If
If TextBox5.Text = "34" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 34")
End If
End If
If TextBox5.Text = "55" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 165")
End If
End If
If TextBox5.Text = "55" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 55")
End If
End If
If TextBox5.Text = "55" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 55")
End If
End If
If TextBox5.Text = "89" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("VINCITA 267")
End If
End If
If TextBox5.Text = "89" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 89")
End If
End If
If TextBox5.Text = "89" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("PERSO 89")
End If
End If
If TextBox3.Text = "1" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 3")
End If
End If
If TextBox3.Text = "1" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 1")
End If
End If
If TextBox3.Text = "1" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 1")
End If
End If
If TextBox3.Text = "2" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 6")
End If
End If
If TextBox3.Text = "2" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 2")
End If
End If
If TextBox3.Text = "2" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 2")
End If
End If
If TextBox3.Text = "3" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 9")
End If
End If
If TextBox3.Text = "3" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 3")
End If
End If
If TextBox3.Text = "3" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 3")
End If
End If
If TextBox3.Text = "5" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 15")
End If
End If
If TextBox3.Text = "5" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 5")
End If
End If
If TextBox3.Text = "5" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 5")
End If
End If
If TextBox3.Text = "8" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 24")
End If
End If
If TextBox3.Text = "8" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 8")
End If
End If
If TextBox3.Text = "8" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 8")
End If
End If
If TextBox3.Text = "13" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 39")
End If
End If
If TextBox3.Text = "13" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 13")
End If
End If
If TextBox3.Text = "13" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 13")
End If
End If
If TextBox3.Text = "21" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 63")
End If
End If
If TextBox3.Text = "21" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 21")
End If
End If
If TextBox3.Text = "21" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 21")
End If
End If
If TextBox3.Text = "34" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 102")
End If
End If
If TextBox3.Text = "34" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 34")
End If
End If
If TextBox3.Text = "34" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 34")
End If
End If
If TextBox3.Text = "55" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 165")
End If
End If
If TextBox3.Text = "55" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 55")
End If
End If
If TextBox3.Text = "55" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 55")
End If
End If
If TextBox3.Text = "89" Then
If Button41.Text = "COLONNA 3" Then
MsgBox("VINCITA 267")
End If
End If
If TextBox3.Text = "89" Then
If Button41.Text = "COLONNA 1" Then
MsgBox("PERSO 89")
End If
End If
If TextBox3.Text = "89" Then
If Button41.Text = "COLONNA 2" Then
MsgBox("PERSO 89")
End If
End If
End Sub
Private Sub Button42_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button42.Click
Button42.Text = ""
Button38.BackColor = Color.Orange
Button38.Text = "GIRA"
Button1.BackColor = Color.Red
Button1.Text = 1
Button2.BackColor = Color.DarkGray
Button2.Text = 2
Button3.BackColor = Color.Red
Button3.Text = 3
Button4.BackColor = Color.DarkGray
Button4.Text = 4
Button5.BackColor = Color.Red
Button5.Text = 5
Button6.BackColor = Color.DarkGray
Button6.Text = 6
Button7.BackColor = Color.Red
Button7.Text = 7
Button8.BackColor = Color.DarkGray
Button8.Text = 8
Button9.BackColor = Color.Red
Button9.Text = 9
Button10.BackColor = Color.DarkGray
Button10.Text = 10
Button11.BackColor = Color.DarkGray
Button11.Text = 11
Button12.BackColor = Color.Red
Button12.Text = 12
Button13.BackColor = Color.DarkGray
Button13.Text = 13
Button14.BackColor = Color.Red
Button14.Text = 14
Button15.BackColor = Color.DarkGray
Button15.Text = 15
Button16.BackColor = Color.Red
Button16.Text = 16
Button17.BackColor = Color.DarkGray
Button17.Text = 17
Button18.BackColor = Color.Red
Button18.Text = 18
Button19.BackColor = Color.Red
Button19.Text = 19
Button20.BackColor = Color.DarkGray
Button20.Text = 20
Button21.BackColor = Color.Red
Button21.Text = 21
Button22.BackColor = Color.DarkGray
Button22.Text = 22
Button23.BackColor = Color.Red
Button23.Text = 23
Button24.BackColor = Color.DarkGray
Button24.Text = 24
Button25.BackColor = Color.Red
Button25.Text = 25
Button26.BackColor = Color.DarkGray
Button26.Text = 26
Button27.BackColor = Color.Red
Button27.Text = 27
Button28.BackColor = Color.DarkGray
Button28.Text = 28
Button29.BackColor = Color.DarkGray
Button29.Text = 29
Button30.BackColor = Color.Red
Button30.Text = 30
Button31.BackColor = Color.DarkGray
Button31.Text = 31
Button32.BackColor = Color.Red
Button32.Text = 32
Button33.BackColor = Color.DarkGray
Button33.Text = 33
Button34.BackColor = Color.Red
Button34.Text = 34
Button35.BackColor = Color.DarkGray
Button35.Text = 35
Button36.BackColor = Color.Red
Button36.Text = 36
Button37.BackColor = Color.Green
Button37.Text = 0
Button46.BackColor = Color.Red
Button46.Text = "ROSSO"
Button47.BackColor = Color.DarkGray
Button47.Text = "NERO"
Button43.BackColor = Color.Orange
Button43.Text = "COL 1"
Button44.BackColor = Color.Orange
Button44.Text = "COL 2"
Button45.BackColor = Color.Orange
Button45.Text = "COL 3"
Button58.Text = "BUDGET"
Button59.Text = "AFTER BET"
Button61.Text = "SE PERDI"
Button61.BackColor = Color.Beige
Button60.Text = "SE VINCI"
Button60.BackColor = Color.DarkSeaGreen
Button55.Text = "COL 1"
Button55.BackColor = Color.Orange
Button54.Text = "COL 2"
Button54.BackColor = Color.Orange
Button53.Text = "COL 3"
Button53.BackColor = Color.Orange
Button57.Text = "ROSSO"
Button57.BackColor = Color.Red
Button56.Text = "NERO"
Button56.BackColor = Color.DarkGray
Button50.Text = "COL 1"
Button50.BackColor = Color.Orange
Button49.Text = "COL 2"
Button49.BackColor = Color.Orange
Button48.Text = "COL 3"
Button48.BackColor = Color.Orange
Button52.Text = "ROSSO"
Button52.BackColor = Color.Red
Button51.Text = "NERO"
Button51.BackColor = Color.DarkGray
End Sub
Private Sub Button48_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button48.Click
Dim num1 As Double
Dim num1a As Double
Dim num2 As Double
Dim somma As Double
num1 = Val(TextBox7.Text)
num1a = Val(TextBox3.Text)
num2 = Val(TextBox3.Text) * 3
somma = num1 - num1a + num2
TextBox6.Text = CStr(somma)
End Sub
Private Sub Button49_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button49.Click
Dim num3 As Double
Dim num3a As Double
Dim num4 As Double
Dim somma As Double
num3 = Val(TextBox7.Text)
num3a = Val(TextBox5.Text)
num4 = Val(TextBox5.Text) * 3
somma = num3 - num3a + num4
TextBox6.Text = CStr(somma)
End Sub
Private Sub Button50_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button50.Click
Dim num5 As Double
Dim num5a As Double
Dim num6 As Double
Dim somma As Double
num5 = Val(TextBox7.Text)
num5a = Val(TextBox2.Text)
num6 = Val(TextBox2.Text) * 3
somma = num5 - num5a + num6
TextBox6.Text = CStr(somma)
End Sub
Private Sub Button51_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button51.Click
Dim num7 As Double
Dim num8 As Double
Dim somma As Double
num7 = Val(TextBox7.Text)
num8 = Val(TextBox4.Text) * 2
somma = num7 + num8
TextBox6.Text = CStr(somma)
End Sub
Private Sub Button52_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button52.Click
Dim num9 As Double
Dim num10 As Double
Dim somma As Double
num9 = Val(TextBox7.Text)
num10 = Val(TextBox1.Text) * 2
somma = num9 + num10
TextBox6.Text = CStr(somma)
End Sub
Private Sub Button53_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button53.Click
Dim num1 As Double
Dim num2 As Double
Dim differenza As Double
num1 = Val(TextBox7.Text)
num2 = Val(TextBox3.Text)
differenza = num1 - num2
TextBox6.Text = CStr(differenza)
End Sub
Private Sub Button54_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button54.Click
Dim num1 As Double
Dim num4 As Double
Dim differenza As Double
num1 = Val(TextBox7.Text)
num4 = Val(TextBox5.Text)
differenza = num1 - num4
TextBox6.Text = CStr(differenza)
End Sub
Private Sub Button55_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button55.Click
Dim num1 As Double
Dim num5 As Double
Dim differenza As Double
num1 = Val(TextBox7.Text)
num5 = Val(TextBox2.Text)
differenza = num1 - num5
TextBox6.Text = CStr(differenza)
End Sub
Private Sub Button56_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button56.Click
Dim num1 As Double
Dim num6 As Double
Dim differenza As Double
num1 = Val(TextBox7.Text)
num6 = Val(TextBox4.Text)
differenza = num1 - num6
TextBox6.Text = CStr(differenza)
End Sub
Private Sub Button57_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button57.Click
Dim num1 As Double
Dim num7 As Double
Dim differenza As Double
num1 = Val(TextBox7.Text)
num7 = Val(TextBox1.Text)
differenza = num1 - num7
TextBox6.Text = CStr(differenza)
End Sub
End Class
PARSING
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim apri As New OpenFileDialog
Dim CulturaUSA As System.Globalization.CultureInfo = System.Globalization.CultureInfo.GetCultureInfo("en-US")
Dim FileDeiPrezzi As String = ""
With apri
.ShowDialog()
If .FileName = String.Empty Then
MsgBox("File Inesistente")
Exit Sub
Else
FileDeiPrezzi = .FileName
End If
End With
Dim DatiNelFile As String = My.Computer.FileSystem.ReadAllText(FileDeiPrezzi)
Dim DatiNelFile_N As String = DatiNelFile.ToLower.Replace(",", " ").Replace(vbCrLf, " ").Replace(" ", " ").Replace(".", " ").Replace("!", " ").Replace("?", " ").Replace(")", " ").Replace("(", " ").Replace("-", " ").Replace("'", " ")
Dim parsing As String() = DatiNelFile_N.Split((vbCrLf & " ").ToCharArray, StringSplitOptions.RemoveEmptyEntries)
MessageBox.Show(" Il testo contiene " & parsing.Length & " parole")
Dim NumeroRiga As Integer
For Each riga As String In parsing
Me.RichTextBox1.AppendText(vbCrLf & " " & riga)
NumeroRiga += 1
Next riga
End Sub
End Class
SCAMBIO FOTOGRAFIE
Public Class Form1
Public alterna As Boolean
Public WithEvents t As New Timer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Pesce\Desktop\costiera.jpg")
Me.PictureBox2.Image = Image.FromFile("C:\Documents and Settings\Pesce\Desktop\roccaraso.jpg")
With Me.t
.Interval = 1000
.Start()
End With
End Sub
Private Sub t_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Tick
Me.scmabiaimmagini()
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click, PictureBox1.Click
If Me.t.Enabled Then
t.Stop()
ElsE
t.Start()
End If
End Sub
Sub scmabiaimmagini()
Dim img As Image = Me.PictureBox1.Image
Me.PictureBox1.Image = Me.PictureBox2.Image
Me.PictureBox2.Image = img
Me.PictureBox1.Top += 6
Me.PictureBox1.Left += 6
Me.PictureBox2.Top -= 6
Me.PictureBox2.Left -= 6
End Sub
End Class
ESERCIZIO SPEZZATE
Public Class Form1
Public WithEvents timer As New Timer
Public b As Bitmap
Public g As Graphics
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.b = New Bitmap(800, 500)
Me.g = Graphics.FromImage(b)
Me.g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Me.g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Me.g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
With Me.timer
.Interval = 500
.Start()
End With
End Sub
Private Sub timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick
Me.disegnaframe()
End Sub
Dim x1 As Integer = 50
Dim y1 As Integer = 50
Dim x2 As Integer = 50
Dim y2 As Integer = 50
Dim x3 As Integer
Dim y3 As Integer
Dim direzione1 As Integer = 1
Dim direzione2 As Integer = 1
Dim direzione3 As Integer = 1
Sub disegnaframe()
g.Clear(Color.Gold)
Dim MyRect As New Rectangle(10, 10, 200, 100)
g.DrawRectangle(Pens.DarkGreen, MyRect)
Dim MyRect2 As New Rectangle(x1, y1, 200, 100)
g.FillRectangle(Brushes.Aqua, MyRect2)
Dim MyRectcerchio As New Rectangle(x2, y2, 50, 50)
g.FillEllipse(Brushes.Orange, MyRectcerchio)
Me.PictureBox1.Image = b
Dim p1 As New Point(x3, y3)
Dim p2 As New Point(0, 0)
Dim p3 As New Point(b.Width, b.Height)
Dim puntispezzata As New List(Of Point)
puntispezzata.Add(p1)
puntispezzata.Add(p2)
puntispezzata.Add(p3)
g.DrawLines(New Pen(Color.Crimson, 2), puntispezzata.ToArray)
If y1 > Me.b.Height - 50 OrElse y1 < 0 Then
direzione1 = -direzione1
End If
If y2 > Me.b.Height - 50 OrElse y2 < 0 Then
direzione2 = -direzione2
End If
If y3 > Me.b.Height - 50 OrElse y3 < 0 Then
direzione3 = -direzione3
End If
x1 += direzione1 * 10
y1 += direzione1 * 10
x2 += direzione2 * 10
y2 += direzione2 * 10
x3 += direzione3 * 10
y3 += direzione3 * 10
End Sub
End Class
ACCESSO A DBMS
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim percorsoDB As String = String.Empty
Dim O As New OpenFileDialog
With O
.ShowDialog()
percorsoDB = .FileName
End With
If percorsoDB = String.Empty Then Exit Sub
Try
Dim stringaconnessione As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & percorsoDB & ";user Id=admin;Password=;"
Dim connessione As New OleDbConnection(stringaconnessione)
connessione.Open()
Dim comandoSQL As String = "SELECT*FROM ORDERS"
Dim comando As New OleDbCommand(comandoSQL, connessione)
Dim lettore As OleDbDataReader = comando.ExecuteReader()
Dim record(lettore.FieldCount - 1) As Object
Do While lettore.Read
lettore.GetValues(record)
Me.RichTextBox1.AppendText(vbCrLf & record(0) & " " & record(1) & " " & record(2))
Loop
MsgBox("Connesso ok")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
QUANT
Public Class Form1
Public Livello_Prezzi As New List(Of Oss)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim somma As Double = 0
Dim somma_quantita_acquistata As Integer = 0
Dim passo As Integer = 1
Dim a As Integer = CInt(Me.NumericUpDown1.Value)
Dim b As Integer = CInt(Me.NumericUpDown2.Value)
Dim Prezzo_iniziale = CDbl(Me.RichTextBox3.Text)
Dim Decremento_prezzo As Integer = CInt(Me.NumericUpDown3.Value)
Dim posizione As Integer = CInt(Me.NumericUpDown4.Value)
Dim quantita_acquistata As Integer = CInt(Me.NumericUpDown4.Value)
Dim valore As Double = 0
Dim P As Double = CDbl(Me.RichTextBox3.Text)
Dim Target As Double = CDbl(Me.RichTextBox2.Text)
Do While P > 0
Dim Buy As New Oss
With buy
somma_quantita_acquistata += quantita_acquistata
.passo = passo
.posizione = posizione
.Valore = valore + P * quantita_acquistata
.Prezzo = P
somma += .Valore
.perdita = .Prezzo * .posizione - .Valore
.P = (.Valore + Target) / .posizione
.retracement = .P - P
.relative_retracement = .retracement / (Prezzo_iniziale - .Prezzo)
.prezzo_medio = somma / somma_quantita_acquistata
.retracement_corrente = .retracement / P
Livello_Prezzi.Add(Buy)
P = P - (a + b * passo) * Decremento_prezzo
passo += 1
posizione = .posizione + quantita_acquistata
valore = .Valore
End With
Loop
Dim string_builder As New System.Text.StringBuilder
string_builder.Append(vbCrLf & "Passo".PadLeft(0) & _
"Posizione".PadLeft(10) & _
"Valore".PadLeft(10) & _
"P_Correnti".PadLeft(20) & _
" PNL".PadLeft(13) & _
"RTC".PadLeft(14) & _
"R_Retracement".PadLeft(17) & _
"P_Medio".PadLeft(17) & _
"RTC_su_prezzo_corrente".PadLeft(25))
For Each modifica As Oss In Livello_Prezzi
With modifica
string_builder.Append(vbCrLf & .passo.ToString.PadLeft(0) & _
.posizione.ToString.PadLeft(10) & _
.Valore.ToString.PadLeft(13) & _
.Prezzo.ToString.PadLeft(17) & _
.perdita.ToString.PadLeft(17) & _
.retracement.ToString(".##").PadLeft(14) & _
.relative_retracement.ToString(".##").PadLeft(17) & _
.prezzo_medio.ToString.PadLeft(17) & _
.retracement_corrente.ToString(".##").PadLeft(18))
End With
Next modifica
Me.RichTextBox1.Text = string_builder.ToString
End Sub
End Class
Public Class Oss
Public Prezzo As Double
Public passo As Integer
Public posizione As Integer
Public Valore As Double
Public perdita As Double
Public P As Double
Public prezzo_medio As Double
Public retracement As Double
Public relative_retracement As Double
Public retracement_corrente As Double
End Class
SERIE STORICA
Public Class Form1
Private b As Bitmap
Private g As Graphics
Private MargineSinistro As Integer = 40
Private MargineDestro As Integer = 40
Private MargineAlto As Integer = 40
Private MargineBasso As Integer = 40
Private MinimoPrezzo As Decimal
Private MassimoPrezzo As Decimal
Private MinimoTempo As Double
Private MassimoTempo As Double
Dim FontPrezzi As New Font("Arial", 10, FontStyle.Bold)
Dim ListaOsservazioni_BID As List(Of Osservazione)
Dim ListaOsservazioni_ASK As List(Of Osservazione)
Dim ListaMedieMobili_BID As List(Of Osservazione)
Dim ListaMedieMobili_ASK As List(Of Osservazione)
Dim ListaSigmaPositivi As List(Of Osservazione)
Dim ListaSigmaNegativi As List(Of Osservazione)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'---------------
'apriamo il file
'---------------
Dim q As New OpenFileDialog
Dim FileDeiPrezzi As String
With q
.ShowDialog()
If String.IsNullOrEmpty(q.FileName) Then Exit Sub
Me.RichTextBox1.Text = q.FileName
My.Computer.FileSystem.ReadAllText(q.FileName)
Me.RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(q.FileName)
If .FileName = String.Empty Then Exit Sub
FileDeiPrezzi = .FileName
End With
Dim DatiTxtContenutiInFile As String = My.Computer.FileSystem.ReadAllText(FileDeiPrezzi)
Dim RigheDelFile As String() = DatiTxtContenutiInFile.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
'----------------------------------
'Ogni riga diventa una osservazione
'----------------------------------
Dim CulturaUSA As System.Globalization.CultureInfo = System.Globalization.CultureInfo.GetCultureInfo("en-US")
ListaOsservazioni_BID = New List(Of Osservazione)
ListaOsservazioni_ASK = New List(Of Osservazione)
ListaMedieMobili_BID = New List(Of Osservazione)
ListaMedieMobili_ASK = New List(Of Osservazione)
ListaSigmaPositivi = New List(Of Osservazione)
ListaSigmaNegativi = New List(Of Osservazione)
For Each Riga As String In RigheDelFile
Dim ValoriInUnaRiga As String() = Riga.Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
Dim Ora As Integer = CInt(ValoriInUnaRiga(0))
Dim Minuti As Integer = CInt(ValoriInUnaRiga(1))
Dim Secondi As Integer = CInt(ValoriInUnaRiga(2))
Dim Millisecs As Integer = CInt(ValoriInUnaRiga(3))
Dim oss As New Osservazione
With oss
.Istante = New Date(Now.Year, Now.Month, Now.Day, Ora, Minuti, Secondi, Millisecs)
.TipoPrezzo = CInt(ValoriInUnaRiga(4))
.Prezzo = Decimal.Parse(ValoriInUnaRiga(5), CulturaUSA)
If .TipoPrezzo = 1 Then
ListaOsservazioni_BID.Add(oss)
ElseIf .TipoPrezzo = 2 Then
ListaOsservazioni_ASK.Add(oss)
End If
End With
Next Riga
'------------------------
'Media mobili prezzi ASK
'------------------------
For i As Integer = k + 1 To ListaOsservazioni_ASK.Count - k - 2
Dim mASK As Double = Me.MediaMobile(ListaOsservazioni_ASK, i)
Dim sASK As Double = Me.sigma(ListaOsservazioni_ASK, i)
Dim oASK As New Osservazione
Dim s1ASK As New Osservazione
Dim s2ASK As New Osservazione
With oASK
.Prezzo = mASK
.Istante = ListaOsservazioni_ASK(i).Istante
End With
ListaMedieMobili_ASK.Add(oASK)
With s1ASK
.Prezzo = mASK + 2 * sASK
.Istante = ListaOsservazioni_ASK(i).Istante
End With
ListaSigmaPositivi.Add(s1ASK)
With s2ASK
.Prezzo = mASK - 2 * sASK
.Istante = ListaOsservazioni_ASK(i).Istante
End With
ListaSigmaNegativi.Add(s2ASK)
Next
'-----------------------
'Media mobile prezzi BID
'-----------------------
For j As Integer = k + 1 To ListaOsservazioni_BID.Count - k - 2
Dim mBID As Double = Me.MediaMobile(ListaOsservazioni_BID, j)
Dim sBID As Double = Me.sigma(ListaOsservazioni_BID, j)
Dim oBID As New Osservazione
Dim s1BID As New Osservazione
Dim s2BID As New Osservazione
With oBID
.Prezzo = mBID
.Istante = ListaOsservazioni_BID(j).Istante
End With
ListaMedieMobili_BID.Add(oBID)
With s1BID
.Prezzo = mBID + 2 * sBID
.Istante = ListaOsservazioni_BID(j).Istante
End With
ListaSigmaPositivi.Add(s1BID)
With s2BID
.Prezzo = mBID - 2 * sBID
.Istante = ListaOsservazioni_BID(j).Istante
End With
ListaSigmaNegativi.Add(s2BID)
Next
Me.DisegnaGRafico()
End Sub
Sub DisegnaGRafico()
If Me.ListaOsservazioni_ASK Is Nothing Then Exit Sub
b = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
g = Graphics.FromImage(b)
'--------------------------------------------------------------------------------------------
' Adesso le 2 liste osservazioni diventano delle liste di punti da rappresentare su un bitmap
'--------------------------------------------------------------------------------------------
Dim ListaDiPunti_BID As List(Of Point) = Me.CreaListaPuntiDaListaOsservazioni(ListaOsservazioni_BID)
Dim ListaDiPunti_ASK As List(Of Point) = Me.CreaListaPuntiDaListaOsservazioni(ListaOsservazioni_ASK)
Dim listaDiPunti_MEDIA_ASK As List(Of Point) = Me.CreaListaPuntiDaListaOsservazioni(ListaMedieMobili_ASK)
Dim listaDiPunti_MEDIA_BID As List(Of Point) = Me.CreaListaPuntiDaListaOsservazioni(ListaMedieMobili_BID)
'------------------
'Visualizzo margini
'------------------
g.DrawRectangle(Pens.White, New Rectangle(Me.MargineSinistro, Me.MargineAlto, b.Width - Me.MargineSinistro - Me.MargineDestro, b.Height - Me.MargineAlto - Me.MargineBasso))
'----------------
'Curve dei prezzi
'----------------
'BID
Dim p_BID As New Pen(Color.Red, 1)
g.DrawLines(p_BID, ListaDiPunti_BID.ToArray)
'ASK
Dim p_ASK As New Pen(Color.Blue, 1)
g.DrawLines(p_ASK, ListaDiPunti_ASK.ToArray)
'MEDIA BID
Dim p_MEDIA_BID As New Pen(Color.Magenta, 1)
g.DrawLines(p_MEDIA_BID, listaDiPunti_MEDIA_BID.ToArray)
'MEDIA ASK
Dim p_MEDIA_ASK As New Pen(Color.LightBlue, 1)
g.DrawLines(p_MEDIA_ASK, listaDiPunti_MEDIA_ASK.ToArray)
'ASSE DEI PREZZI
Me.DrawPriceRuler()
Dim drawfont3 As New Font("Arial", 8)
g.FillRectangle(Brushes.Red, Me.PictureBox1.Width - 100, Me.PictureBox1.Height - 90, 5, 5)
g.DrawString("Bid", drawfont3, Brushes.White, Me.PictureBox1.Width - 130, Me.PictureBox1.Height - 92)
g.FillRectangle(Brushes.Blue, Me.PictureBox1.Width - 100, Me.PictureBox1.Height - 75, 5, 5)
g.DrawString("Ask", drawfont3, Brushes.White, Me.PictureBox1.Width - 130, Me.PictureBox1.Height - 77)
g.FillRectangle(Brushes.Magenta, Me.PictureBox1.Width - 100, Me.PictureBox1.Height - 105, 5, 5)
g.DrawString("MM_Bid", drawfont3, Brushes.White, Me.PictureBox1.Width - 150, Me.PictureBox1.Height - 107)
g.FillRectangle(Brushes.LightBlue, Me.PictureBox1.Width - 100, Me.PictureBox1.Height - 120, 5, 5)
g.DrawString("MM_Ask", drawfont3, Brushes.White, Me.PictureBox1.Width - 150, Me.PictureBox1.Height - 122)
Dim drawFont As New Font("Arial", 10)
Dim drawFont2 As New Font("Arial", 12, FontStyle.Bold)
g.DrawString("Serie storica dei prezzi", drawFont2, Brushes.Black, 380, 10)
g.DrawString("Prezzo", drawFont, Brushes.Black, 10, 10)
g.DrawString("Tempo", drawFont, Brushes.Black, Me.PictureBox1.Width - 67, Me.PictureBox1.Height - 20)
Me.PictureBox1.Image = b
End Sub
Function CreaListaPuntiDaListaOsservazioni(ByVal ListaOsservazioni As List(Of Osservazione)) As List(Of Point)
'------------------------------------------
'Determinazione del minimo e massimo prezzo
'------------------------------------------
Dim TempoOrigine As Date = New Date(Now.Year, Now.Month, Now.Day, 0, 0, 0)
Me.MinimoPrezzo = Decimal.MaxValue
Me.MassimoPrezzo = Decimal.MinValue
Me.MinimoTempo = Double.MaxValue
Me.MassimoTempo = Double.MinValue
For Each h As Osservazione In ListaOsservazioni
With h
'prezzo
If MinimoPrezzo > .Prezzo Then MinimoPrezzo = .Prezzo
If MassimoPrezzo < .Prezzo Then MassimoPrezzo = .Prezzo
'tempo
Dim Tempo As Double = .Istante.Subtract(TempoOrigine).TotalMilliseconds
If MinimoTempo > Tempo Then MinimoTempo = Tempo
If MassimoTempo < Tempo Then MassimoTempo = Tempo
End With
Next h
Dim ListaPunti As New List(Of Point)
For Each o As Osservazione In ListaOsservazioni
With o
'Determinazione il punto
Dim x As Double = .Istante.Subtract(TempoOrigine).TotalMilliseconds
Dim y As Decimal = .Prezzo
'Trasformarmazione il punto per rappresentarlo sul bitmap
Dim X_Sul_Bitmap As Integer = Me.Trasforma_X(x, MinimoTempo, MassimoTempo, MargineSinistro, MargineDestro)
Dim Y_Sul_Bitmap As Integer = Me.Trasforma_Y(y, MinimoPrezzo, MassimoPrezzo, MargineAlto, MargineBasso)
Dim p As New Point(X_Sul_Bitmap, Y_Sul_Bitmap)
ListaPunti.Add(p)
End With
Next o
Return ListaPunti
End Function
Function Trasforma_X(ByVal x As Double, ByVal MinX As Double, ByVal MaxX As Double, _
ByVal MarginLeft As Integer, ByVal MarginRight As Integer) As Integer
Dim X_Trasformata As Integer = MarginLeft + CInt((Me.b.Width - MarginLeft - MarginRight) * (x - MinX) / (MaxX - MinX))
Return X_Trasformata
End Function
Function Trasforma_Y(ByVal y As Double, ByVal MinY As Double, ByVal MaxY As Double, _
ByVal MarginTop As Integer, ByVal MarginBottom As Integer) As Integer
Dim Y_Trasformata As Integer = Me.b.Height - MarginTop - CInt((Me.b.Height - MarginTop - MarginBottom) * (y - MinY) / (MaxY - MinY))
Return Y_Trasformata
End Function
Sub DrawPriceRuler()
Dim NumeroSuddivisioni As Integer = 10
Dim Passo As Double = (Me.MassimoPrezzo - Me.MinimoPrezzo) / NumeroSuddivisioni
Dim Prezzo As Double = Me.MinimoPrezzo
Do
Prezzo += Passo
If Prezzo > Me.MassimoPrezzo Then Exit Do
'--------------------------------
'Disegno della tacca e del prezzo
'--------------------------------
Dim Y_Bitmap = Me.Trasforma_Y(Prezzo, Me.MinimoPrezzo, Me.MassimoPrezzo, Me.MargineAlto, Me.MargineBasso)
Me.g.DrawString(Prezzo.ToString, Me.FontPrezzi, Brushes.White, Me.MargineSinistro + 5, Y_Bitmap)
Loop
End Sub
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Me.DisegnaGRafico()
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
Me.k = Me.NumericUpDown1.Value
Me.DisegnaGRafico()
End Sub
Public k As Integer
Function MediaMobile(ByVal v As List(Of Osservazione), ByVal posizione As Integer)
Dim somma As Double
Dim media As Double
Dim conta As Double
For i As Integer = posizione - k To posizione + k
somma += v(i).Prezzo
conta += 1
Next
media = somma / conta
Return media
End Function
Function sigma(ByVal v As List(Of Osservazione), ByVal posizione As Integer)
Dim somma As Double
Dim media As Double
Dim conta As Double
Dim Scarti As Double
Dim scartiQuadrati As Double
Dim varianza As Double
Dim deviazione As Double
For i As Integer = posizione - k To posizione + k
somma += v(i).Prezzo
conta += 1
media = somma / conta
Scarti = v(i).Prezzo - media
scartiQuadrati = Scarti ^ 2
varianza = scartiQuadrati / conta
Next
deviazione = Math.Sqrt(varianza)
Return deviazione
End Function
Public Class Osservazione
Public Istante As Date
Public TipoPrezzo As Integer
Public Prezzo As Decimal
End Class
End Class
TRADING
Public Class Form1
Private b As Bitmap
Private g As Graphics
'imposta i margini
Private MargineSinistro As Integer = 40
Private MargineDestro As Integer = 40
Private MargineAlto As Integer = 40
Private MargineBasso As Integer = 40
Private MinimoPrezzo As Decimal
Private MassimoPrezzo As Decimal
Private MinimoTempo As Double
Private MassimoTempo As Double
'creiamo la lista dei punti della curva
Dim ListaPunti As List(Of Point)
Public PrezziRandom As List(Of Oss)
Public Ordine = New List(Of DeltaP)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.resetgrafica()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Button1.Enabled = True
Me.RichTextBox1.Clear()
If Me.Button3.CanSelect Then
RW()
Else : GBM()
End If
DisegnaGRafico()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Target As Double = Double.Parse(Me.NumericUpDown3.Value)
Dim PrezzoIniziale = Double.Parse(Me.NumericUpDown4.Value)
Dim NumeroAcquisti As Integer = 0
Dim NumeroVendite As Integer = 0
Dim AmmontareAcquistato As Double = 0
Dim AmmontareVenduto As Double = 0
Dim Posizione As Integer = 0
Dim Profitto As Double = 0
Dim a As Double = Double.Parse(Me.NumericUpDown1.Value)
Dim Minimo_Prezzo_Acquisto = PrezzoIniziale
Button2.Enabled = True
Dim Decremento As Double = Double.Parse(Me.NumericUpDown2.Value)
Dim i As Integer = 1 '-1
For Each o As Oss In PrezziRandom
i += 1
'compra titoli
If o.Prezzo <= Minimo_Prezzo_Acquisto - (a * Decremento) Then
Dim Acquista As New DeltaP
With Acquista
.Istante = o.Istante
.isBuy = True
.Quantita = 1
.PrezzoCorrente = o.Prezzo
AmmontareAcquistato += .PrezzoCorrente * .Quantita
Posizione += .Quantita
.PNL = AmmontareVenduto - AmmontareAcquistato
.Minimo_Prezzo_Acquisto = .PrezzoCorrente
Minimo_Prezzo_Acquisto = .PrezzoCorrente
Ordine.Add(Acquista)
End With
g = Graphics.FromImage(b)
Dim Penna As New Pen(Color.Blue, 1)
g.DrawLine(Penna, ListaPunti(i).X, MargineAlto, ListaPunti(i).X, b.Height - Me.MargineBasso)
Me.PictureBox1.Image = b
NumeroAcquisti += 1
'vende titoli
ElseIf (o.Prezzo * Posizione >= AmmontareAcquistato + Target) Then
Dim Vendi As New DeltaP
AmmontareVenduto += o.Prezzo * Posizione
With Vendi
.PrezzoCorrente = o.Prezzo
.PNL = AmmontareVenduto - AmmontareAcquistato
.isBuy = False
.Minimo_Prezzo_Acquisto = .PrezzoCorrente
Minimo_Prezzo_Acquisto = .PrezzoCorrente
Ordine.Add(Vendi)
End With
g = Graphics.FromImage(b)
Dim Penna As New Pen(Color.Red, 1)
g.DrawLine(Penna, ListaPunti(i).X, MargineAlto, ListaPunti(i).X, b.Height - Me.MargineBasso)
Me.PictureBox1.Image = b
NumeroVendite += 1
Posizione = 0
Profitto += Vendi.PNL
AmmontareAcquistato = 0
AmmontareVenduto = 0
End If
Next
'Visualizziamo nella RichTextBox1 il numero delle vendite, degli acquisti e PNL
Me.RichTextBox1.Clear()
Me.RichTextBox1.AppendText(vbCrLf & " Vendite " & NumeroVendite)
Me.RichTextBox1.AppendText(vbCrLf & " Acquisti " & NumeroAcquisti)
Me.RichTextBox1.AppendText(vbCrLf & " PNL " & Profitto - AmmontareAcquistato)
End Sub
Public r As New Random
Sub GBM()
'generiamo i prezzi da un moto browniano
Dim PrezzoIniziale As Decimal = Double.Parse(Me.NumericUpDown4.Value)
Dim IstanteIniziale As Date = Now
Dim T_Size As Decimal = 0.01
'Primo prezzo della serie
Dim PrezzoCorrente As Decimal = PrezzoIniziale
Dim IstanteCorrente As Date = IstanteIniziale
Dim ListaPrezzi As New List(Of Oss)
Dim Oss1 As New Oss
With Oss1
.Istante = IstanteCorrente
.Prezzo = PrezzoCorrente
End With
ListaPrezzi.Add(Oss1)
'Prezzi successivi
Dim Media As Double = 0
Dim Volatilita As Double = 0.02
Do
Dim T_Span As New TimeSpan(0, 0, 0, 0, r.Next(1, 5) * 1000)
'Generiamo una normale
Dim u1 As Double = r.NextDouble
Dim u2 As Double = r.NextDouble
Dim Normale_Standard As Double = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2)
Dim T As Double = T_Span.TotalDays / 252 'anni
Dim Mean As Double = (Media - Volatilita * Volatilita / 2) * T
Dim Sigma As Double = Volatilita * Math.Sqrt(T)
Dim Normale As Double = Me.Normale_Non_STardard(Normale_Standard, Mean, Sigma)
' Discretizzazione incremento
Dim NuovoPrezzo As Double = PrezzoCorrente * Math.Exp(Normale)
Dim DifferenzaRispettoPrecedenteInTicks As Integer = CInt((NuovoPrezzo - PrezzoCorrente) / T_Size)
PrezzoCorrente = PrezzoCorrente + DifferenzaRispettoPrecedenteInTicks * T_Size
'--
IstanteCorrente = IstanteCorrente.AddMilliseconds(T_Span.TotalMilliseconds)
Dim NewOss As New Oss
With NewOss
.Istante = IstanteCorrente
.Prezzo = PrezzoCorrente
End With
ListaPrezzi.Add(NewOss)
If IstanteCorrente.Subtract(IstanteIniziale).TotalHours > 23 Then Exit Do
Loop
PrezziRandom = ListaPrezzi
End Sub
Function Normale_Non_STardard(ByVal Normale_STandard As Double, ByVal Mean As Double, ByVal Sigma As Double) As Double
Return Normale_STandard * sigma + Mean
End Function
Sub RW()
'generiamo i prezzi da un Random Walk
Dim PrezzoIniziale As Decimal = Double.Parse(Me.NumericUpDown4.Value)
Dim Conta_Minuti As Integer = 0
Dim IstanteIniziale As Date = Now
Dim Tick As Decimal = 1
Dim T_Span As New TimeSpan(0, 0, 0, 0, r.Next(1, 5) * 1000)
Dim PrezzoCorrente As Decimal = PrezzoIniziale
Dim IstanteCorrente As Date = IstanteIniziale
Dim ListaPrezzi As New List(Of Oss)
Do
If r.NextDouble > 0.5 Then
PrezzoCorrente += Tick
Else
PrezzoCorrente -= Tick
End If
IstanteCorrente = IstanteCorrente.AddMilliseconds(T_Span.TotalMilliseconds)
Dim NewOss As New Oss
With NewOss
.Istante = IstanteCorrente
.Prezzo = PrezzoCorrente
End With
ListaPrezzi.Add(NewOss)
If IstanteCorrente.Subtract(IstanteIniziale).TotalHours > 23 Then Exit Do
Loop
PrezziRandom = ListaPrezzi
End Sub
Function CreaListaPuntiDaListaOsservazioni(ByVal ListaOsservazioni As List(Of Oss)) As List(Of Point)
'modifico TempoOrigine
Dim TempoOrigine As Date = New Date(Now.Year - 1, Now.Month, Now.Day, 0, 0, 0)
Me.MinimoPrezzo = Decimal.MaxValue
Me.MassimoPrezzo = Decimal.MinValue
Me.MinimoTempo = Double.MaxValue
Me.MassimoTempo = Double.MinValue
'Troviamo il minimo ed il massimo per gestire la grafica
For Each Oss As Oss In ListaOsservazioni
With Oss
'prezzo
If MinimoPrezzo > .Prezzo Then MinimoPrezzo = .Prezzo
If MassimoPrezzo < .Prezzo Then MassimoPrezzo = .Prezzo
'tempo
Dim Tempo As Double = .Istante.Subtract(TempoOrigine).TotalMilliseconds
If MinimoTempo > Tempo Then MinimoTempo = Tempo
If MassimoTempo < Tempo Then MassimoTempo = Tempo
End With
Next Oss
Dim ListaPunti As New List(Of Point)
For Each Oss As Oss In ListaOsservazioni
With Oss
'Determinare il punto!
Dim x As Double = .Istante.Subtract(TempoOrigine).TotalMilliseconds
Dim y As Decimal = .Prezzo
'Trasformare il punto per rappresentarlo sul bitmap!
Dim X_Sul_Bitmap As Integer = Me.Trasforma_X(x, MinimoTempo, MassimoTempo, MargineSinistro, MargineDestro)
Dim Y_Sul_Bitmap As Integer = Me.Trasforma_Y(y, MinimoPrezzo, MassimoPrezzo, MargineAlto, MargineBasso)
Dim p As New Point(X_Sul_Bitmap, Y_Sul_Bitmap)
ListaPunti.Add(p)
End With
Next Oss
Return ListaPunti
End Function
'rendiamo la X relativa per usarla nel grafico
Function Trasforma_X(ByVal x As Double, ByVal MinX As Double, ByVal MaxX As Double, _
ByVal MarginLeft As Integer, ByVal MarginRight As Integer) As Integer
Dim X_Trasformata As Integer = MarginLeft + CInt((Me.b.Width - MarginLeft - MarginRight) * (x - MinX) / (MaxX - MinX))
Return X_Trasformata
End Function
'rendiamo la Y relativa per usarla nel grafico
Function Trasforma_Y(ByVal y As Double, ByVal MinY As Double, ByVal MaxY As Double, _
ByVal MarginTop As Integer, ByVal MarginBottom As Integer) As Integer
Dim Y_Trasformata As Integer = Me.b.Height - MarginTop - CInt((Me.b.Height - MarginTop - MarginBottom) * (y - MinY) / (MaxY - MinY))
Return Y_Trasformata
End Function
'resetta la grafica
Sub resetgrafica()
b = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
g = Graphics.FromImage(b)
End Sub
Sub DisegnaGRafico()
If Me.PrezziRandom Is Nothing Then Exit Sub
'pulisce l'area del grafico da eventuali grafici precedenti
g.Clear(Color.Black)
' Adesso la lista osservazioni diventa lista di punti da rappresentare su un bitmap
'creiamo la lista dei punti
ListaPunti = CreaListaPuntiDaListaOsservazioni(PrezziRandom)
'Visualizziamo i margini
g.DrawRectangle(Pens.Black, New Rectangle(Me.MargineSinistro, Me.MargineAlto, _
b.Width - Me.MargineSinistro - Me.MargineDestro, b.Height -Me.MargineAlto - Me.MargineBasso))
'Curva dei prezzi
Dim Penna_Prezzi As New Pen(Color.Red, 1)
g.DrawLines(Penna_Prezzi, ListaPunti.ToArray)
Me.PictureBox1.Image = b
End Sub
'ridisegnamo il grafico in caso di resize
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Me.resetgrafica()
Me.DisegnaGRafico()
End Sub
Private Sub button3_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Button4.Enabled = True
Me.Button3.Enabled = False
Me.Button2.Text = "plot random walk curve"
Me.Button1.Text = "buy\sel random walk mode"
End Sub
Private Sub button4_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Button3.Enabled = True
Me.Button4.Enabled = False
Me.Button2.Text = "plot random brawnian"
Me.Button1.Text = "buy\sel random brownian mode"
End Sub
End Class
Public Class DeltaP
Public Istante As Date
Public Quantita As Integer
Public isBuy As Boolean
Public PrezzoCorrente As Double
Public PNL As Double
Public Minimo_Prezzo_Acquisto As Double
End Class
Public Class Oss
Public Istante As Date
Public TipoPrezzo As Integer
Public Prezzo As Decimal
End Class




