Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
| Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 28th, 2011, 05:43 PM
Registered User
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check Boxes: Writing Results to Text File and Formatting Properly

Hello, everyone. This is my first post, and I'm a novice. I'm using Visual Basic 6, running on Windows 7 32-bit.

I need help with check boxes, please. I've written a rudimentary program that does nothing more than let me type text into a few text boxes, click a button, and have that text stored in a file.

Right now, the form has just a few text boxes, and a command button to generate the file. It works.

I'm going to complicate the project by adding a group of check boxes. I've only now just begun to research check boxes, but I haven't figured out how to get all of the checked options to be displayed on one line, separated by commas.

To elaborate:

Just for demonstration, let's say I have six check boxes in a check box group named HOBBIES. The six choices are:

1. Bicycling
2. Painting
3. Cooking
4. Dining Out
5. Strength Training
6. Playing Saxophone

Let's say someone selects the following three options:

Dining Out
Playing Saxophone

I'd like the line in the text file to be displayed like this, including the header:

Hobbies: Painting, Dining Out, Playing Saxophone

Is this possible?

Also, to make the procedure even more complicated, I want to have TWO separate lines of text for HOBBIES, only if four or more items are selected.

Example: If the following five options are selected:

1. Bicycling
2. Painting
3. Cooking
4. Dining Out
5. Strength Training

Then the program should put the following two lines in the text file, formatted thusly (double-spaced):

Hobbies: Bicycling, Painting, Cooking

Hobbies: Dining Out, Strength Training

Being a novice, I'm wondering if I'm making this too complicated. On the other hand, it's a reasonable challenge that hopefully will improve my coding skills.

Without actually providing me with code, what would be the best way to proceed with this goal?

Thank you to anyone and everyone who'd be kind enough to assist. Jack D.
  #2 (permalink)  
Old May 29th, 2011, 08:55 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

Probably the gurus that write books will have a better answer, but in your case, although using VB6 is too old, you could investigate about control collections (see the index property of the control)... Take in mind, that when you migrate to a newer language, they will disappear...

Also, the way you put things in the file is up to you.. So that's not very complicate...


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
================================================== =========
I know that CVS was evil, and now i got the
================================================== =========

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing to Text File striker9 ASP.NET 2.0 Basics 1 May 12th, 2006 05:17 AM
writing text file but in an order specifed... stone XSLT 2 October 27th, 2005 05:17 AM
Dynamic check boxes writing to database..help!! cincinnaticj7 Classic ASP Databases 0 January 25th, 2005 10:47 AM
Reading from a text file and writing to a Binary 1 scott01 C++ Programming 0 July 28th, 2003 03:59 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.