I am trying to populate listview from another form textbox i
I am trying to populate listview from another form textbox in visual basic. Form 1 has the listview and a button to take you to form 2. When you get to form 2 there is a textbox for student name and a textbox for score. Then a button add student that takes those text boxes and puts the information back into form 1 listview. It has been a long time since I have coded with visual basic and I can not seem to get the correct format. When I enter my information into the text boxes on form 2 nothing happens. Here is my forms so far.
**** form 1***
Option Strict On
Public Class Form1
Dim frmForm2 As Form
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(5000)
End Sub
Private Sub btnTestScores_Click(sender As Object, e As EventArgs) Handles btnTestScores.Click
frmForm2 = Form2
frmForm2.Show()
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
End Class
**** form 2****
Public Class Form2
Private Sub txtStudentName_TextChanged(sender As Object, e As EventArgs) Handles txtStudentName.TextChanged
End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim strName As String
Dim decScore As Decimal
Try
strName = txtStudentName.Text
decScore = CDec(txtScore.Text)
Form1.ListView1.SelectedItems(0).SubItems(0).Text = strName.ToString
Form1.ListView1.SelectedItems(0).SubItems(1).Text = decScore.ToString
Catch ex As Exception
Return
End Try
End Sub
End Class
Solution
Public Class Form1
Dim frmForm2 As Form
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(5000)
End Sub
Private Sub btnTestScores_Click(sender As Object, e As EventArgs) Handles btnTestScores.Click
frmForm2 = Form2
frmForm2.Show()
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
End Class
**** form 2****
Public Class Form2
Private Sub txtStudentName_TextChanged(sender As Object, e As EventArgs) Handles txtStudentName.TextChanged
End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim strName As String
Dim decScore As Decimal
Try
strName = txtStudentName.Text
decScore = txtScore.Text
Form1.ListView1.SelectedItems(0).SubItems(0).Text = strName.ToString
Form1.ListView1.SelectedItems(0).SubItems(1).Text = decScore.ToString
Catch ex As Exception
Return
End Try
End Sub
End Class

