Scusa ancora.
cmq il codice è
codice:
Public Class Form1
Private ele(-1) As azione
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = "0"
TextBox1.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MessageBox.Show("Inserisci un carattere nel nome")
TextBox1.Text = ""
TextBox1.Focus()
Exit Sub
End If
If TextBox2.Text = "" Then
MessageBox.Show("Inserisci un carattere nella categoria")
TextBox2.Text = ""
TextBox2.Focus()
Exit Sub
End If
If RadioButton2.Checked Then
TextBox3.Text = 0
ElseIf TextBox3.Text = "" Or TextBox3.Text <= 0 Then
MessageBox.Show("Inserisci un valore")
TextBox3.Text = "0"
TextBox3.Focus()
Exit Sub
End If
ReDim Preserve ele(ele.Length)
ele(ele.Length - 1).nome = TextBox1.Text
ele(ele.Length - 1).categoria = TextBox2.Text
ele(ele.Length - 1).prezzo = Convert.ToDecimal(TextBox3.Text)
MessageBox.Show("Inserimento effettuato")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = "0"
TextBox1.Focus()
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
TextBox3.Enabled = True
TextBox3.Text = "0"
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
TextBox3.Enabled = False
TextBox3.Text = "0"
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
Dim x As Integer = 0
Dim riga As ListViewItem
Select Case TabControl1.SelectedIndex
Case 0 : Exit Select
Case 1
ListView1.Items.Clear()
For x = 0 To ele.Length - 1
riga = New ListViewItem(ele(x).nome)
riga.SubItems.Add(ele(x).categoria)
riga.SubItems.Add(ele(x).prezzo)
ListView1.Items.Add(riga)
Next
Case Else
End Select
End Sub
End Class
E nel modulo ho la struttura.
Io vorrei fare in modo che inserisco una cosa nel vettore di struttura, poi una volta inserita, alla fine dell'evento button1.click mi salvi quello appena inserito in un txt.. Capito?