Forum Moderators: open

Message Too Old, No Replies

Need help with forms vb.net

         

jefferson

3:06 pm on Oct 4, 2005 (gmt 0)

10+ Year Member



I have a form(Form1). There is a button on it that shows another form(form2).

DIM newform as form2
form2.show

I want to run some code on form1 when form2 is closed. How would i go about doing this.

Easy_Coder

5:06 pm on Oct 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put that code in it's own object so you can fire it from anywhere...

jefferson

5:20 pm on Oct 4, 2005 (gmt 0)

10+ Year Member



Ok here is the code that i am trying to fire. What kind of File does this need to go in, why the hell am i so confused? i've done this before, but i can't remember when or how

Private Sub FillAccountList()
If txtMedRecNo.Text = "" Then
Exit Sub
Else
rsACCOUNTS = New ADODB.Recordset
rsACCOUNTS.Open("SELECT * FROM ACCOUNTS WHERE MRNumber = " & txtMedRecNo.Text & " order by timein desc", CN, 1, 2)

lstAccounts.Items.Clear()

While (Not rsACCOUNTS.EOF)
lstAccounts.Items.Add((rsACCOUNTS.Fields("AcctNo").Value) & " " & (rsACCOUNTS.Fields("Timein").Value))
rsACCOUNTS.MoveNext()
End While
End If
rsACCOUNTS.Close()
If lstAccounts.Items.Count = 0 Then
lstAccounts.Enabled = False
Else
lstAccounts.SelectedIndex = 0
lstAccounts.Enabled = True
End If
End Sub

Easy_Coder

9:24 pm on Oct 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would create an Accounts Object Accounts.vb and have a method called AccountList that returned a DataSet.

pseudo class code

class Accounts
{
public DataSet AccountList()
{
// create connection...

// create command

// create sql data adapter

// create dataset

// fill the adapter

return dataset;
}
}

BradleyT

6:16 am on Oct 5, 2005 (gmt 0)

10+ Year Member



If you're going to use vb.net you should also take advantage of ADO.net and get rid of that sucky ADODB recordset.