On Feb 6, 2006, at 2:56 PM, Mark Cooke wrote:

Hi,

I'm writing a very simple account program (only for myself), not coming from an event or Multiple window coding environment (mainly terminal based programs), I was wondering of the best and cleanest way of passing data between two windows.

Here my setup:

I have MainWindow, this holds A toolbar with New, Edit and Delete toolbaritems, under this is a 8 column ListBox,
this holds each transaction for the current window.

If you Click New or Edit, this opens up the relevant window, here you can add the new transaction infomation to several
EditFileds and Checkboxes etc..,
It's at this point, I'm wondering about the best way to pass the data back to the MainWindow.LBTransactions.

At present I have some very simple code in the SaveButton for the Action Event, in the TransactionsWindow, it does some validation and checking of the data in this window, then passes the details back to the MainWindow.LBTransactions, using the details below.

  MainWindow.LBTransactions.addrow ""
MainWindow.LBTransactions.cell (MainWindow.LBTransactions.lastIndex,0 )= DateField.Text MainWindow.LBTransactions.cell (MainWindow.LBTransactions.lastIndex,1) = AmountField.Text MainWindow.LBTransactions.cell (MainWindow.LBTransactions.lastIndex,2) = DescriptionComboBox.Text MainWindow.LBTransactions.cell (MainWindow.LBTransactions.lastIndex,3) = CategoryComboBox.Text MainWindow.LBTransactions.cell (MainWindow.LBTransactions.lastIndex,4) = PaymentMethodComboBox.Text MainWindow.LBTransactions.cell (MainWindow.LBTransactions.lastIndex,6) = NotesField.Text



This looks very messy and clumsy, the other option could be to use a For..Loop, and inside this add a Select Case to populate the required cells of the ListBox.

Any advise would be appreciated.


You can pass a reference to LBTransactions to the TransactionsWindow when you open it. For example in New or Edit:

dim w as new TransactionsWindow(self.LBTransactions)

Add a property to TransactonsWindow: mLB as listbox, and a method:

TransactionsWindow(LB as ListBox)
self.mLB = LB

Then after your validation in the SaveButton do:

dim s as string
s = DateField.Text + chr(9) + AmountField.Text + chr(9) + DescriptionComboBox.Text + chr(9) + ... // add the remaining
LB.addrow ""
LB.Cell(LB.LastIndex,-1) = s


Jack

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to