473,382 Members | 1,165 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,382 software developers and data experts.

How to Print The Values of Multiple Checkboxes in VB6

I am adding to my software. I have placed about 30 checkboxes on a form. Based on which checkboxes are selected, I want to print the values to a tab delimited text file. For instance, the first checkbox is labeled "Depth" and corresponds to a named variable of 'depth'. If this checkbox is select, I want to print column A, or 'depth' to the file. This part is easy. I am looking for the simplest way to write to a tab delimited text file, if there are multiple checkboxes selected, say 20. But I am wanting the column to print in a certain order. My named variables are: depth(column1),fph(column2),mpf(column3),slide(col umn4),pdc(column5),tgas(column6),etc. Now if checkboxes "Depth", "MPF" , "Slide", & "TGas" were selected, I need the values of the columns to print in a certain order: depth, fph, mpf, slide, pdc, tgas, etc. The code I have so far is as follows:
Expand|Select|Wrap|Line Numbers
  1. Public Sub PrintColumns()
  2. With frmHeader
  3.     'all columns
  4.     If .colFPH.Value = 1 And .colMPF.Value = 1 And .colTGas.Value = 1 _
  5.         And .colMeth.Value = 1 And .colEth.Value = 1 And .colPro.Value = 1 And .colIBut.Value = 1 _
  6.         And .colNBut.Value = 1 And .colMWtIn.Value = 1 And .colMWtOut.Value = 1 And .colMTmpIn.Value = 1 _
  7.         And .colMTmpOut.Value = 1 And .colAnhy.Value = 1 And .colChalk.Value = 1 And .colLime.Value = 1 _
  8.         And .colDolo.Value = 1 And .colShale.Value = 1 And .colSand.Value = 1 And .colSilt.Value = 1 _
  9.         And .colCoal.Value = 1 And .colChert.Value = 1 And .colNoSamp.Value = 1 Then
  10.             Print #1, depth & vbTab & fph & vbTab & mpf & vbTab & slide & vbTab & _
  11.                 pdc & vbTab & tgas & vbTab & c1 & vbTab & c2 & vbTab & c3 & vbTab & _
  12.                 c4i & vbTab & c4n & vbTab & shale & vbTab & silt & vbTab & _
  13.                 sand & vbTab & chalk & vbTab & lime & vbTab & dolo & vbTab & _
  14.                 anhy & vbTab & coal & vbTab & chert & vbTab & nosamp & vbTab & _
  15.                 mwin & vbTab & mwout & vbTab & mtmpin & vbTab & mtmpout
  16.     End If
  17.  
  18.     If .colFPH.Value = 1 Then
  19.         Print #1, depth & vbTab & fph
  20.     End If
  21.     If .colMPF.Value = 1 Then
  22.         Print #1, depth & vbTab & mpf
  23.     End If
  24.     If .colSlide.Value = 1 Then
  25.         Print #1, depth & vbTab & slide
  26.     End If
  27.     If .colPDC.Value = 1 Then
  28.         Print #1, depth & vbTab & pdc
  29.     End If
  30.     If .colTGas.Value = 1 Then
  31.         Print #1, depth & vbTab & tgas
  32.     End If
  33.     If .colMeth.Value = 1 Then
  34.         Print #1, depth & vbTab & c1
  35.     End If
  36.     If .colEth.Value = 1 Then
  37.         Print #1, depth & vbTab & c2
  38.     End If
  39.     If .colPro.Value = 1 Then
  40.         Print #1, depth & vbTab & c3
  41.     End If
  42.     If .colIBut.Value = 1 Then
  43.         Print #1, depth & vbTab & c4i
  44.     End If
  45.     If .colNBut.Value = 1 Then
  46.         Print #1, depth & vbTab & c4n
  47.     End If
  48.     If .colMWtIn.Value = 1 Then
  49.         Print #1, depth & vbTab & mwin
  50.     End If
  51.     If .colMWtOut.Value = 1 Then
  52.         Print #1, depth & vbTab & mwout
  53.     End If
  54.     If .colMTmpIn.Value = 1 Then
  55.         Print #1, depth & vbTab & mtmpin
  56.     End If
  57.     If .colMTmpOut.Value = 1 Then
  58.         Print #1, depth & vbTab & mtmpout
  59.     End If
  60.     If .colAnhy.Value = 1 Then
  61.         Print #1, depth & vbTab & anhy
  62.     End If
  63.  
  64.  
  65.     'fph & mpf
  66.     If .colFPH.Value = 1 And .colMPF.Value = 1 Then
  67.         Print #1, depth & vbTab & fph & vbTab & mpf
  68.     End If
  69.     'fph,mpf,& tgas
  70.     If .colFPH.Value = 1 And .colMPF.Value = 1 And .colTGas.Value = 1 Then
  71.         Print #1, depth & vbTab & fph & vbTab & mpf & vbTab & tgas
  72.     End If
  73.  
  74. End With
  75.  
  76. End Sub
  77.  
If I keep writing it like I am, I will have around 2000 lines of code to write, just to get the logic correct. Does anyone have a simpler way of doing this? I have about 25 columns of data, and only want the ones that are referenced by the checkboxes to print to a tab delimited file, but in a specific order. Any ideas?
Feb 8 '10 #1
0 1355

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Emmett Power | last post by:
Hi, I have a form on a web page with a number of radio buttons bound to the same field. Is it possible to set up the form so that users can select more than one radio button to submit multiple...
3
by: Garmt de Vries | last post by:
On the website of the Dutch Jules Verne Society (www.jules-verne.nl), we have several forms that visitors can use to order something, or to apply for membership. Of course, a form's primary purpose...
0
by: elgin | last post by:
I have a form which is formatted so as to print out for mailing. This form contains several option groups with checkboxes. These checkboxes have no data source; the state of the checkboxes are...
29
by: Amer Neely | last post by:
I've got a dynamically built form with checkboxes for each element ( a list of file names in a directory). I need to grab only those checkboxes that are checked, so I can then delete those files. ...
5
by: ameshkin | last post by:
What I want to do is very simple, but I'm pretty new at PHP and its a little hard for me. I have one page, where there are a rows of checkboxes. A button selects all checkboxes, and then...
1
by: prash.marne | last post by:
hi , i am having a simple form ----------------------------------------------------------------------- ----------------------------------------------------------------------- --------------...
9
by: =?Utf-8?B?UGV0ZXJX?= | last post by:
I have a TabControl on a Windows form in which I have various tab pages each with a DataGridView, the first column of which is a DataGridViewCheckBoxColumn and subsequent columns being...
10
by: LionsDome | last post by:
Hello, I have a vb.net page which a bunch of checkboxes. A user can select a checkbox(s) and hit the submit button to store those values in a SQL Server table. This works fine with no problem...
5
by: TechnoAtif | last post by:
Hi All..'mAtif..i've got stuck within checkboxes these days..i've got many input items like checkboxes,textarea and along with them there are many checkboxes...all the data except the checkbox's is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.