473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Writing to a sequential file from various child forms



Using a menu item to write to a sequential file from the parent form, what
code and where would I put it to write the text values, settings, bool
values from various child menues?
Feb 7 '07 #1
6 1159
Cashewz <ca*****@imnutz.comwrote in
news:Xn*********************@216.196.97.131:
>

Using a menu item to write to a sequential file from the parent form,
what code and where would I put it to write the text values, settings,
bool values from various child menues?

Can anyone help? Please??
Feb 7 '07 #2
Cashewz wrote:
Using a menu item to write to a sequential file from the parent form, what
code and where would I put it to write the text values, settings, bool
values from various child menues?
I'm not entirely clear on what you're trying to do.

Your menu item, as defined in a "Parent Form" wants to write "values" to
a text file. So far, so good. StreamWriters are your friend here.

Don't put this code into the Click Event handler for the menu item.
Add a method to your Form that does this work and call that from the
menu item.

If you're working with /inherited/ Forms, make the method "Protected"
rather than "Private".

If necessary, code this method to iterate [recursively] through the
contents of the MainMenu property of the Form but, if you're doing what
I /think/ you're doing, I'd recommend coding for each relevant item
manually.

HTH,
Phill W.
Feb 12 '07 #3
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in
news:eq**********@south.jnrs.ja.net:
Cashewz wrote:
>Using a menu item to write to a sequential file from the parent form,
what code and where would I put it to write the text values,
settings, bool values from various child menues?

I'm not entirely clear on what you're trying to do.

Your menu item, as defined in a "Parent Form" wants to write "values"
to a text file. So far, so good. StreamWriters are your friend here.

Don't put this code into the Click Event handler for the menu item.
Add a method to your Form that does this work and call that from the
menu item.

If you're working with /inherited/ Forms, make the method "Protected"
rather than "Private".

If necessary, code this method to iterate [recursively] through the
contents of the MainMenu property of the Form but, if you're doing
what I /think/ you're doing, I'd recommend coding for each relevant
item manually.

HTH,
Phill W.
Thanks. The book i'm dealing with is, in my opinion, quite poor to learn
from: Advanced Programming with Microsoft, Visual Basic .NET, A case-
based approach by "Bob Spear". My teacher, nice woman that she is, isn't
the hands-on type. She doesn't put examples out on the class web page,
and the once a week class goes over the topics AFTTER they have been
assigned (and are due).

In any case, i'm now learning to love setting public variables in a
module for all my child-parent variable needs. ;)

Feb 13 '07 #4
In any case, i'm now learning to love setting public variables in a
module for all my child-parent variable needs. ;)
I find it is generally best to avoid public class members, and instead
access them through properties. Properties are a nicer way of handling
getter/setter code, and I usually add input validation into any set
procedure, to make sure that any values passed are OK, and to take any
extra action that needs to be done.

Feb 13 '07 #5
Just to add one other item to the list.

It makes debugging much easier. Using properties allows the setting of
breakpoints while debugging to sort out the "who set that value" problem.

LS

<lo*********@gmail.comwrote in message
news:11********************@h3g2000cwc.googlegroup s.com...
>
>In any case, i'm now learning to love setting public variables in a
module for all my child-parent variable needs. ;)

I find it is generally best to avoid public class members, and instead
access them through properties. Properties are a nicer way of handling
getter/setter code, and I usually add input validation into any set
procedure, to make sure that any values passed are OK, and to take any
extra action that needs to be done.
Feb 13 '07 #6
Cashewz wrote:
In any case, i'm now learning to love setting public variables in a
module for all my child-parent variable needs. ;)
Good for you.

Now, go and slap yourself [hard] around the face a few times and stop
doing this.

"Public Variables in a Module" = "Global variable".

These are Bad.

The Good News:
You can access them from anywhere in your project and set them to any
value you want, whenever you need to.

The Bad news.
You can access them from anywhere in your project and set them to any
value.

As an [artificial] example:

Module Globals
Public MonthAbbrevs As String () = { "Jan", ..., "Dec" }
Public Month as Integer = 2
End Module

Class X
Public Sub New()
Console.Writeline( Me.GetMonthname() ) ' OK
Me.SomeMethod()
Console.Writeline( Me.GetMonthname() ) ' BOOM
End Sub
Private Sub SomeMethod()
Globals.Month = 77
End Sub
Private Function GetMonthname() As String
Return Globals.MonthAbbrevs(Globals.Month - 1)
End Sub
End Class

At the very least, wrap your "globals" in Properties; that way you can
protect against this kind of corruption and, if you /do/ start getting
some odd values appearing unexpectedly, you can pop a breakpoint in the
Property to find out /where/ the dodgy data is coming from - try doing
the same with just a global variable!

Regards,
Phill W.
Feb 14 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: lawrence | last post by:
I asked a lot of questions in May about how to organize OO code. I didn't get great answers here, but someone here suggested that I look the Eclipse library, which was a good tip. Looking at its...
10
by: Neil Trigger | last post by:
Is there a way of creating a seperate text file on a server every time a form is sent? -- ¿ Trigger ? http://www.magic2k.com/ http://www.oddmap.co.uk
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
1
by: rayw | last post by:
I was wondering if there were some good on-line references to the various pros/cons with these types of file access at all? Ta rayw
8
by: asrs63 | last post by:
Hi, I am a newbee and have a comma seperated flat-file and a DTD. I need to write a C# program which will read the text file and convert it to a XML file as per the the definition in the DTD. I...
3
by: Zeke Zinzul | last post by:
Hi Guys & Geeks, What's the most elegant way of dealing with binary data and structures? Say I have this (which I actually do, a woo-hoo): struct Struct_IconHeader { byte width; byte...
11
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.