martedì 11 gennaio 2011

Esercizi esonero - Marco Orsi

Esercizi esonero - Marco Orsi

--Esercizio 1 - Parsing

Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



'Creo una classe attraverso la quale si richiede all'utente l'apertura di un file.

Dim ApriFile As New OpenFileDialog





'Il programma deve leggere il file con la cultura che è stata impostata.



' Da informazioni su una lingua specifica, nel nostro caso “cultura Usa”. Come per esempio, i 'nomi della lingua, il sistema di scrittura, il calendario usato e le norme di formattazione 'delle date e ordinamento delle stringhe.



Dim CulturaUSA As System.Globalization.CultureInfo = System.Globalization.CultureInfo.GetCultureInfo("en-US")



'Creo una stringa in cui inseriremo il percorso del file.

Dim FileDeiPrezzi As String = ""



'Cerco il file da splittare

With ApriFile

'Permette di visualizzare una finestra di dialogo.

.ShowDialog()





' “.FileName” fornisce il percorso del file. Si verifica che l'utente abbia scelto



' un file.



'Successivamente assegno a “FileDeiPrezzi” il percorso.



If .FileName = String.Empty Then

MsgBox("File Inesistente")

Exit Sub

Else

FileDeiPrezzi = .FileName

End If

End With



'Per restituire il contenuto di un file di testo come Stringa, ovvero di tipo String, è necessaria l’istruzione “My.Computer.FileSystem.ReadAllText”.

Dim DatiInclusiNelFile As String = My.Computer.FileSystem.ReadAllText(FileDeiPrezzi)



'E’ necessario normalizza il file, cioè togliere una serie di caratteri e renderlo tutto in minuscolo.

Dim DatiInclusiNelFile_N As String = DatiInclusiNelFile.ToLower.Replace(",", " ").Replace(vbCrLf, " ").Replace(" ", " ").Replace(".", " ").Replace("!", " ").Replace("?", " ").Replace(")", " ").Replace("(", " ").Replace("-", " ").Replace("'", " ")



'Parsing dei dati.

Dim parsing As String() = DatiInclusiNelFile_N.Split((vbCrLf & " ").ToCharArray, StringSplitOptions.RemoveEmptyEntries)



'Nella RichTextBox1 visualizzo un messaggio relativo al numero di parole

Me.RichTextBox1.Text = " Il testo contiene " & parsing.Length & " parole"



End Sub

End Class
 
--Esercizio 2A - Immagini 
 
Public Class Form1


Public alterna As Boolean



'Definisco il timer.

Public WithEvents t As New Timer





'Per caricare le immagini definisco il percorso e si scambiano nelle due PictureBox.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Me.PictureBox1.Image = Image.FromFile("C:\Users\Marco\Desktop\auto.jpg")

Me.PictureBox2.Image = Image.FromFile("C:\Users\Marco\Desktop\moto.jpg")

With Me.t

.Interval = 1000 '1000 millesecondi.

.Start() 'Avvio timer.

End With

End Sub





'Definisce l'evento Tick.

Private Sub t_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Tick





'Le immagini si spostano.

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





'Facciamo muovere le due immagini

Me.PictureBox1.Top += 8

Me.PictureBox1.Left += 8



Me.PictureBox2.Top -= 8

Me.PictureBox2.Left -= 8



End Sub



End Class
 
--Esercizio 2B - Forme
 
ublic Class Form1




'Implemento un timer con il quale viene generato un evento a intervalli definito dall'utente.

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(500, 300)

Me.g = Graphics.FromImage(b)



'Specifica se l'arrotondamento viene applicato alle linee e alle curve e ai bordi delle aree riempite.

Me.g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality

'Specifica la qualita di rendering del testo.

Me.g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

'Specifica l'algoritmo utilizzato quando le immagini vengono scalate o ruotate.

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 = 30

Dim y2 As Integer = 20

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.Violet)



Dim MyRect As New Rectangle(10, 10, 200, 100) 'Memorizzo un set di quattro interi che rappresentano la posizione e le dimensioni di un rettangolo.

g.DrawRectangle(Pens.Green, MyRect)



Dim MyRect2 As New Rectangle(x1, y1, 200, 100)

g.FillRectangle(Brushes.Aquamarine, MyRect2)



Dim MyRectcerchio As New Rectangle(x2, y2, 50, 50)

g.FillEllipse(Brushes.Blue, MyRectcerchio)



Me.PictureBox1.Image = b

'"Point" rappresenta una coppia ordina di coordinate x e y intere, che definisce un punto in un piano bidimensionale.

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)

'Pen definisce un oggetto usato per disegnare linee e curve.

g.DrawLines(New Pen(Color.Yellow, 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
 
--Esrcizio 3 - Serie storica
 
Public Class Form1




Private b As Bitmap

Private g As Graphics



Private MargineSinistro As Integer = 20

Private MargineDestro As Integer = 20



Private MargineAlto As Integer = 20

Private MargineBasso As Integer = 20



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)

' Creazione delle osservazioni: per ciascuna riga creo un oggetto.

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





'Classe che non puo essere ereditata, che richiede all'utente l'apertura di un file.

Dim q As New OpenFileDialog

' permette di inserire il percorso del file.

Dim FileDeiPrezzi As String



With q

'Apre una finestra di dialogo.

.ShowDialog()

' “.FileName” fornisce il percorso del file. Si verifica che l'utente abbia scelto

' un file.

'Successivamente assegno a “FileDeiPrezzi” il percorso.



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



'Legge tutto il file in una stringa.

Dim DatiTxtContenutiInFile As String = My.Computer.FileSystem.ReadAllText(FileDeiPrezzi)

'Si hanno le righe presenti nel file e ottenute con la funzione split

Dim RigheDelFile As String() = DatiTxtContenutiInFile.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)





'Ogni riga diventa una osservazione.

'Il programma deve leggere il file con la cultura che è stata impostata.

' Da informazioni su una lingua specifica, nel nostro caso “cultura Usa”. Come per esempio,

'i nomi della lingua, il sistema di scrittura, il calendario usato e le norme di formattazione

'delle date e ordinamento delle stringhe.





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)



'Indicazione del sigificato dei valori nel foglio di dati

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))



'Riempimento delle liste.

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)





'Visualizza i 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)

'Si definisce l'area di disegno.

'Si inserisce la leggenda.

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)

'Impostiamo le etichette, la loro dimensione e il loro carattere.

Dim drawFont As New Font("Arial", 10)

Dim drawFont2 As New Font("Arial", 12, FontStyle.Bold)

'Disegnano le curve dei prezzi.

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)



'Si determina il 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



'Si Determina il punto.

Dim x As Double = .Istante.Subtract(TempoOrigine).TotalMilliseconds

Dim y As Decimal = .Prezzo



'Si Trasforma il punto per rappresentarlo sul bitmap, 'richiamando le funzioni TrasformaX e TrasformaY come segue.

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

'Le seguenti funzioni sono delle trasformazioni lineari che restituiscono le coordinate del punto.

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



'Si disegnano delle tacche e il 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

' Funzione che implementa le medie mobili.

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
 
--Esercizio 4 - Accesso DBMS
 
Imports System.Data


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

'Richiede all'utente l'apertura di un file.

Dim o As New OpenFileDialog

With o

.ShowDialog()

PercorsoDB = .FileName

End With

If PercorsoDB = String.Empty Then Exit Sub

Try

'Definisce una connessione aperta a un' origine dati.

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()

'Comando

Dim ComandoSQL As String = "SELECT * FROM ORDERS"

'Rappresenta un istruzione SQL da seguire in relazione a un' origine dati.

Dim comando As New OleDbCommand(ComandoSQL, connessione)

'Fornisce un modo per leggere un flusso di righe di dati.

Dim Lettore As OleDbDataReader = comando.ExecuteReader()

'Lettore DBMS.

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("Connessione effettuata")



Catch ex As Exception 'Rappresenta gli errori che si verificano durante l'esecuzione dell'applicazione.

MsgBox(ex.Message)

End Try



End Sub



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load



End Sub

End Class

--Esercizio 5 - Word Cloud
 
'Per poter iniziare dobbiamo innanzitutto importare le seguenti classi


Imports System.Drawing.Drawing2D

Imports System.Drawing.Text

Imports System.Drawing.Imaging.ImageFormat



Public Class Form1

'Si richiede all'utente di scegliere un tipo di carattere tra quelli installati nel pc.

'Possibilità di scegliere il font.

Public font1 As New FontDialog



Public b As Bitmap 'Oggetto usato per operare con immagini definite da dati pixel.

Public g As Graphics 'Incapsula una superficie di disegno.

'Si crea un nuovo dizionario (System.Collections.Generic.Dictionary) la cui chiave è una stringa

'che conterrà tutte le parole che non vogliamo inserire nella word cloud.

Dim ListaParoleInutili As New Dictionary(Of String, Boolean) 'Rappresenta un insieme di chiavi e valori.



Dim carattere As Font 'Definisce un particolare formato per il testo(carattere, dimensioni e attributi di stile).

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Rimuove tutti gli elementi dall'insieme ListBox1.

ListBox1.Items.Clear()

'Rappresenta i tipi di carattere nella ListBox1, che sono installati nel sistema.

Dim fonts As New InstalledFontCollection

' "FontFamily" definisce un gruppo di tipi di carattere.

For Each one As FontFamily In fonts.Families

ListBox1.Items.Add(one.Name)

Next



'Si definiscono le parole che non si vogliono inserire nella nuvola.

ListaParoleInutili.Add("di", Nothing)

ListaParoleInutili.Add("a", Nothing)

ListaParoleInutili.Add("da", Nothing)

ListaParoleInutili.Add("in", Nothing)

ListaParoleInutili.Add("con", Nothing)

ListaParoleInutili.Add("su", Nothing)

ListaParoleInutili.Add("per", Nothing)

ListaParoleInutili.Add("tra", Nothing)

ListaParoleInutili.Add("fra", Nothing)

ListaParoleInutili.Add("il", Nothing)

ListaParoleInutili.Add("la", Nothing)

ListaParoleInutili.Add("lo", Nothing)

ListaParoleInutili.Add("un", Nothing)

ListaParoleInutili.Add("una", Nothing)

ListaParoleInutili.Add("uno", Nothing)

ListaParoleInutili.Add("del", Nothing)

ListaParoleInutili.Add("dello", Nothing)

ListaParoleInutili.Add("degli", Nothing)

ListaParoleInutili.Add("dei", Nothing)

ListaParoleInutili.Add("i", Nothing)

ListaParoleInutili.Add("le", Nothing)

ListaParoleInutili.Add("alle", Nothing)

ListaParoleInutili.Add("agli", Nothing)

ListaParoleInutili.Add("dai", Nothing)

ListaParoleInutili.Add("fa", Nothing)

ListaParoleInutili.Add("ci", Nothing)

ListaParoleInutili.Add("si", Nothing)

ListaParoleInutili.Add("e", Nothing)

End Sub





Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

'Si introduce la possibilità di eliminare delle parole che si ritengono superflue

'anche se non sono incluse nella lista delle parole inutili, inserendole tramite una InputBox.



Dim inutile As String

inutile = Microsoft.VisualBasic.Interaction.InputBox("Inserisci la parola che vuoi ignorare! (premere di nuovo il pulsante -Crea Word Tag-)", "Parole Da Ignorare", "")



'Le parole verrano trasformate in minuscolo e verranno inserite nella lista, dopo aver controllato che non siano già presenti.

If ListaParoleInutili.ContainsKey(inutile.ToLower) Then

Else

ListaParoleInutili.Add(inutile.ToLower, Nothing)

End If



End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Il costrutto "try catch" è un meccanismo di intercettazione degli errori runtime.

Try



'Si effettua la lettura del testo.

Dim Corpus As String = Me.RichTextBox1.Text

'E lo si normalizza.

Dim corpus_N As String = Corpus.ToLower.Replace(",", " ").Replace(vbCrLf, " ").Replace(" ", " ").Replace(".", " ").Replace("!", " ").Replace("?", " ").Replace(")", " ").Replace("(", " ").Replace("-", " ").Replace("'", " ")

'Viene inserito in una lista.

Dim Parole() As String = corpus_N.Split((vbCrLf & " ").ToCharArray, StringSplitOptions.RemoveEmptyEntries)

'Si definisce la dimensione minima e massima del font nella nuvola dei punti.

Dim minimadimensionefont As Integer = 20

Dim massimadimensionefont As Integer = 55



'Si definisce una "SortedList"(che rappresenta un insieme di coppie chiave/valore ordinate per chiave)

'che includerà tutte le parole da rappresentare.

Dim ListaParoleDiverse As New SortedList(Of String, Boolean)



'Si inseriscono le parole nella "SortedList".

For Each parola As String In Parole

If Not ListaParoleInutili.ContainsKey(parola) Then

If Not ListaParoleDiverse.ContainsKey(parola) Then ListaParoleDiverse.Add(parola, Nothing)

End If

Next



'Si definisce l'oggetto grafico.

b = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)

g = Graphics.FromImage(b)

g.Clear(Color.Black) 'Si sceglie il colore.

'"SmoothingMode" specifica se l'arrotondamento viene applicato alle linee e alle curve e ai bordi delle aree riempite (imposta la qualità di rendering dell'oggetto grafico).

g.SmoothingMode = SmoothingMode.HighQuality

'"TextRenderingHint" specifica la qualità di rendering del testo.

g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias





'Si genera un punto casuale in cerchio di raggio pari a 1/3 all'altezza della picture box.

Dim RND As New Random 'Generatore di numeri pseudo-casuali.

Dim NumeroCasuale0_1 As Double = RND.NextDouble

Dim Raggio As Double = b.Height / 3



'Si crea una lista di colori.

Dim colorNames As String() = System.Enum.GetNames(GetType(KnownColor)) '"KnownColor" specifica i colori di sistema noti.

Dim lstColors As New List(Of String)(colorNames)





Dim PathRettangoli As New GraphicsPath 'Rappresenta una serie di curve e di linee collegate.



Do While ListaParoleDiverse.Count > 0



'Si disegna ogni parola monitorando che non si sovrappongano e che siano proporzionali alla loro frequenza assoluta.

Dim Parola As String = ListaParoleDiverse.Keys.Item(0)

Dim frequenza As Integer = 1

'Si calcola la frequenza di ogni parola.

For Each parolina As String In Parole

If parolina = Parola Then

frequenza += 1

End If

Next

'Si imposta la dimensione del font.

Dim dimensione As Single = 4 * frequenza



'Si calcola un punto casuale all'interno del cerchio.

Dim ANgoloCasuale As Double = RND.NextDouble * 2 * Math.PI

Dim DIstanzaCasuale As Double = RND.NextDouble * Raggio



'Attraverso una trasformazione lineare, si calcolano le coordinate all'interno della picture box.

Dim x As Double = b.Width / 2 + Math.Cos(ANgoloCasuale) * DIstanzaCasuale

Dim y As Double = b.Height / 2 + Math.Sin(ANgoloCasuale) * DIstanzaCasuale



'Si assegna un colore in modo casuale.

Dim IndiceCasuale As Integer = RND.Next(0, lstColors.Count - 1)

Dim COloreCasuale As Color = System.Drawing.Color.FromName(lstColors(IndiceCasuale))



'Si imposta il font che è stato scelto dall'utente.

Dim MyFont As Font = New Font(ListBox1.Text, dimensione, FontStyle.Italic)





'Si misurano le dimensioni della parola e si verifica che non vi sia sovrapposizione con le altre.

Dim SIzeFString As SizeF = g.MeasureString(Parola, MyFont)

Dim RettangoloStringa As New Rectangle(New Point(x, y), SIzeFString.ToSize)

'Si descrive la perte interna di una forma composta da rettangoli e tracciati.

Dim R As New Region(PathRettangoli)

If Not R.IsVisible(RettangoloStringa) Then

'Se non si sovrappone, si disegna.

g.DrawString(Parola, MyFont, New SolidBrush(COloreCasuale), x, y)

ListaParoleDiverse.RemoveAt(0)

PathRettangoli.AddRectangle(RettangoloStringa)

End If

Me.PictureBox1.Image = b



'Application.DoEvents() è un metodo, mentre il codice gestisce l'evento, l'applicazione non risponde.

Application.DoEvents()



Loop

Catch exc As Exception

'Si gestisce l'errore visualizzando un messaggio del tipo : "Errore non previsto".

MsgBox("Errore non previsto" & vbCrLf & exc.Message)



End Try

Me.PictureBox1.Image = b



End Sub



End Class

--Esercizio 6 - Trading strategy
 
Public Class Form1


'Si crea la lista che conterrà il livello dei prezzi.

Public LivelliPrezzi As New List(Of OSSERVAZIONE)



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Si definisce e si inizializzano delle variabili.

Dim s As Double = 0

Dim sqa As Integer = 0

Dim O_Step As Integer = 1

Dim m As Integer = CInt(Me.NumericUpDown1.Value)

Dim k As Integer = CInt(Me.NumericUpDown2.Value)

Dim DecrementoPrezzo As Integer = CInt(Me.NumericUpDown3.Value)

Dim pos As Integer = CInt(Me.NumericUpDown4.Value)

Dim Qacquistata As Integer = CInt(Me.NumericUpDown4.Value)

Dim pxq As Double = 0

Dim PrezzoIniziale = CDbl(Me.TextBox1.Text)

Dim P As Double = CDbl(Me.TextBox1.Text)

Dim target As Double = CDbl(Me.TextBox2.Text)



'

Do While P > 0

Dim buy As New OSSERVAZIONE

With buy

'Si incrementa la quantità acquistata e o_step.

sqa += Qacquistata

.O_Step = O_Step



.pos = pos



'Si incremente prezzo*quantità.

.PXQ = pxq + P * Qacquistata



.Prezzo = P

s += .PXQ

.LOST = .Prezzo * .pos - .PXQ

.P = (.PXQ + target) / .pos

.RTC = .P - P



If PrezzoIniziale = .Prezzo Then

.RTCR = 0

Else

.RTCR = .RTC / (PrezzoIniziale - .Prezzo)

End If



.pmedio = s / Qacquistata

.RTCC = .RTC / P



LivelliPrezzi.Add(buy)



P = P - (k + m * O_Step) * DecrementoPrezzo

O_Step += 1

pos = .pos + Qacquistata

pxq = .PXQ



End With

Loop





'"StringBuilder" rappresenta una stringa mutabile di caratteri,creiamo cosi il testo da far visualizzare poi nella RichTextBox1.

Dim STRINBUILDER As New System.Text.StringBuilder

Me.RichTextBox1.Text = ("step position prezzi*quantità prezzi correnti PNL RTR RTR RELATIVO ")



STRINBUILDER.Append(vbCrLf & "step".PadLeft(0) & _

"position".PadLeft(10) & _

"valore".PadLeft(8) & _

"prezzi correnti".PadLeft(20) & _

" PNL".PadLeft(5) & _

"RRT".PadLeft(15) & _

"RTR RELATIVO".PadLeft(20) & _

"Prezzo Medio".PadLeft(18) & _

"RTR SU PREZZO CORRENTE".PadLeft(25))

STRINBUILDER.Append(vbCrLf & "" & New String("*"c, 125))



For Each variazione As OSSERVAZIONE In LivelliPrezzi

With variazione

STRINBUILDER.Append(vbCrLf & .O_Step.ToString.PadLeft(2) & _

.pos.ToString.PadLeft(10) & _

.PXQ.ToString("###.##").PadLeft(10) & _

.Prezzo.ToString("###.##").PadLeft(15) & _

.LOST.ToString("###.##").PadLeft(11) & _

.RTC.ToString("###.##").PadLeft(15) & _

.RTCR.ToString("###.##").PadLeft(18) & _

.pmedio.ToString("###.##").PadLeft(15) & _

.RTCC.ToString("###.##").PadLeft(15))

End With

Next variazione



'Si scrivono le osservazioni nella RichTextBox1.

Me.RichTextBox1.Text = STRINBUILDER.ToString

End Sub



End Class



Public Class OSSERVAZIONE

Public O_Step As Integer

Public pos As Integer

Public PXQ As Double

Public Prezzo As Double

Public LOST As Double

Public P As Double

Public RTC As Double

Public RTCR As Double

Public pmedio As Double

Public RTCC As Double

End Class
 
--Esercizio 7 - Trading Algorithm
 
ublic Class Form1


Private b As Bitmap

Private g As Graphics



'Si impostano dei margini sinistro e destro, alto e basso.

Private MargineSinistro As Integer = 60

Private MargineDestro As Integer = 40



Private MargineAlto As Integer = 40

Private MargineBasso As Integer = 40

'Si imposta il minimo e massimo prezzo.

Private MinimoPrezzo As Decimal

Private MassimoPrezzo As Decimal

'Si imposta il minimo e massimo tempo.

Private MinimoTempo As Double

Private MassimoTempo As Double



'Si crea una lista che conterrà i punti della curva, "Point" rappresenta una coppia ordinata di coordinate x e y intere.

Dim ListaDiPuntiGrafico As List(Of Point)



Public PrezziCasuali As List(Of Osservazione)

Public Ordini = New List(Of VariazionePrezzo)







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

' Button2, attivato solo se si è scelto un generatore, attiva button1, dice quale generatore usare

' e richiama DisegnaGrafico.

Me.Button1.Enabled = True



If RadioButton1.Checked Then GeneratorePrezziRW()

If RadioButton2.Checked Then GeneratorePrezziGBM()



DisegnaGRafico()

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



'Si legge il target ed il prezzo iniziale.

Dim target As Double = Double.Parse(Me.TextBox2.Text)

Dim PrezzoIniziale = Double.Parse(Me.TextBox1.Text)

Dim ContaAcquisti As Integer = 0

Dim ContaVendite As Integer = 0

Dim ValoreAcquistato As Double = 0

Dim ValoreVenduto As Double = 0

Dim Posizione As Integer = 0

Dim guadagno As Double = 0

Dim k As Double = Double.Parse(Me.NumericUpDown1.Value)

Dim MinPrezzoBuy = PrezzoIniziale



Dim decremento As Double = Double.Parse(Me.NumericUpDown2.Value)



Dim i As Integer = -1



For Each o As Osservazione In PrezziCasuali

i += 1

'Si comprano i titoli.

If o.Prezzo <= MinPrezzoBuy - (k * decremento) Then



Dim buy As New VariazionePrezzo

With buy

.Istante = o.Istante

.isBuy = True

.quantita = 1

.PrezzoCorrente = o.Prezzo

ValoreAcquistato += .PrezzoCorrente * .quantita

Posizione += .quantita

.PNL = ValoreVenduto - ValoreAcquistato

.minPrezzoBuy = .PrezzoCorrente

MinPrezzoBuy = .PrezzoCorrente



Ordini.Add(buy)

End With

g = Graphics.FromImage(b)

Dim pen_point As New Pen(Color.Fuchsia, 1)

g.DrawLine(pen_point, ListaDiPuntiGrafico(i).X, MargineAlto, ListaDiPuntiGrafico(i).X, b.Height - Me.MargineBasso)

Me.PictureBox1.Image = b



ContaAcquisti += 1



'Si vendono i titoli.

ElseIf (o.Prezzo * Posizione >= ValoreAcquistato + target) Then



Dim vendita As New VariazionePrezzo

ValoreVenduto += o.Prezzo * Posizione

With vendita

.PrezzoCorrente = o.Prezzo

.PNL = ValoreVenduto - ValoreAcquistato

.isBuy = False

.minPrezzoBuy = .PrezzoCorrente

MinPrezzoBuy = .PrezzoCorrente

Ordini.Add(vendita)

End With



g = Graphics.FromImage(b)

Dim pen_point As New Pen(Color.Gold, 1)

g.DrawLine(pen_point, ListaDiPuntiGrafico(i).X, MargineAlto, ListaDiPuntiGrafico(i).X, b.Height - Me.MargineBasso)



Me.PictureBox1.Image = b

ContaVendite += 1

Posizione = 0





guadagno += vendita.PNL

ValoreAcquistato = 0

ValoreVenduto = 0



End If

Next



'Nella RichTextBox1 si visualizza il numero degli acquisti, delle vendite e il PNL del giorno

'dopo avereliminato i messaggi precendenti.

Me.RichTextBox1.Clear()

Me.RichTextBox1.AppendText(vbCrLf & " numero acquisti " & ContaAcquisti)

Me.RichTextBox1.AppendText(vbCrLf & " numero vendite " & ContaVendite)

Me.RichTextBox1.AppendText(vbCrLf & " PNL del giorno " & guadagno - ValoreAcquistato)



End Sub



Public r As New Random



Sub GeneratorePrezziGBM()

'Si generano i prezzi da un moto browniano.



Dim PrezzoIniziale As Decimal = Double.Parse(Me.TextBox1.Text)

Dim IstanteIniziale As Date = Now

Dim TickSize As Decimal = 0.01



'Primo prezzo della serie.



Dim PrezzoCorrente As Decimal = PrezzoIniziale

Dim IstanteCorrente As Date = IstanteIniziale



Dim ListaPrezzi As New List(Of Osservazione)

Dim PrimaOsservazione As New Osservazione



With PrimaOsservazione

.Istante = IstanteCorrente

.Prezzo = PrezzoCorrente

End With

ListaPrezzi.Add(PrimaOsservazione)





'Prezzi successivi.



Dim Parametro_Mu As Double = 0

Dim Parametro_Vol As Double = 0.02





Do



Dim TSpan As New TimeSpan(0, 0, 0, 0, r.Next(1, 5) * 1000)



'Si genera una normale con certa media e certo sigma.



Dim u1 As Double = r.NextDouble

Dim u2 As Double = r.NextDouble

Dim NormalStandard As Double = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2)



Dim T As Double = TSpan.TotalDays / 252 'anni

Dim Media As Double = (Parametro_Mu - Parametro_Vol * Parametro_Vol / 2) * T

Dim std As Double = Parametro_Vol * Math.Sqrt(T)

Dim Normal As Double = Me.NOrmaleNonSTardard(NormalStandard, Media, std)









'Discretizzazione incremento ----------



Dim NuovoPrezzo As Double = PrezzoCorrente * Math.Exp(Normal)

Dim DifferenzaRispettoPrecedenteInTicks As Integer = CInt((NuovoPrezzo - PrezzoCorrente) / TickSize)



PrezzoCorrente = PrezzoCorrente + DifferenzaRispettoPrecedenteInTicks * TickSize

'--------------------------------------



IstanteCorrente = IstanteCorrente.AddMilliseconds(TSpan.TotalMilliseconds)



Dim NewOsservazione As New Osservazione

With NewOsservazione

.Istante = IstanteCorrente

.Prezzo = PrezzoCorrente

End With



ListaPrezzi.Add(NewOsservazione)



If IstanteCorrente.Subtract(IstanteIniziale).TotalHours > 23 Then Exit Do 'Oppure qualche giorno ...



Loop

PrezziCasuali = ListaPrezzi



End Sub



Sub GeneratorePrezziRW()

'Si generano i prezzi da un Random Walk.



Dim PrezzoIniziale As Decimal = Double.Parse(Me.TextBox1.Text)

Dim contatoreMinuti As Integer = 0

Dim IstanteIniziale As Date = Now

Dim Tick As Decimal = 1

Dim TSpan 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 Osservazione)



Do

If r.NextDouble > 0.5 Then

PrezzoCorrente += Tick

Else

PrezzoCorrente -= Tick

End If



IstanteCorrente = IstanteCorrente.AddMilliseconds(TSpan.TotalMilliseconds)



Dim NewOsservazione As New Osservazione

With NewOsservazione

.Istante = IstanteCorrente

.Prezzo = PrezzoCorrente

End With



ListaPrezzi.Add(NewOsservazione)



If IstanteCorrente.Subtract(IstanteIniziale).TotalHours > 23 Then Exit Do

Loop



PrezziCasuali = ListaPrezzi





End Sub





Function NOrmaleNonSTardard(ByVal NOrmaleSTandard As Double, ByVal Media As Double, ByVal std As Double) As Double

Return NOrmaleSTandard * std + Media

End Function





Function CreaListaPuntiDaListaOsservazioni(ByVal ListaOsservazioni As List(Of Osservazione)) As List(Of Point)



'Si modifica "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



'Si cercano il minimo ed il massimo in modo da gestire la grafica.

For Each Osservazione As Osservazione In ListaOsservazioni

With Osservazione



'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 Osservazione



Dim ListaPunti As New List(Of Point)

For Each Osservazione As Osservazione In ListaOsservazioni



With Osservazione



'Si determina il punto.

Dim x As Double = .Istante.Subtract(TempoOrigine).TotalMilliseconds

Dim y As Decimal = .Prezzo



'Si Trasforma 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 Osservazione



Return ListaPunti



End Function



'Si rende 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



'Si rende 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





'Si resetta la grafica.

Sub resetgrafica()

b = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)

g = Graphics.FromImage(b)

End Sub



Sub DisegnaGRafico()



If Me.PrezziCasuali Is Nothing Then Exit Sub



'Si ripulisce l'area del grafico da eventuali grafici precedenti.

g.Clear(Color.Black)





' Adesso lista osservazioni diventa lista di punti da rappresentare su un bitmap





'Si crea la lista dei punti.

ListaDiPuntiGrafico = CreaListaPuntiDaListaOsservazioni(PrezziCasuali)





'Si visualizzano 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 pen_prezzi As New Pen(Color.Red, 1)

g.DrawLines(pen_prezzi, ListaDiPuntiGrafico.ToArray)



Me.PictureBox1.Image = b



End Sub



'Si ridisegna 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



'Con i comandi seguenti si attivano Button2 una volta scelto il generatore dei prezzi.

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

Me.Button2.Enabled = True

End Sub



Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

Me.Button2.Enabled = True

End Sub



End Class





Public Class VariazionePrezzo



Public Istante As Date

Public quantita As Integer

Public isBuy As Boolean

Public PrezzoCorrente As Double

Public PNL As Double

Public minPrezzoBuy As Double

End Class





Public Class Osservazione



Public Istante As Date

Public TipoPrezzo As Integer

Public Prezzo As Decimal



End Class

Nessun commento:

Posta un commento

Nota. Solo i membri di questo blog possono postare un commento.