473,748 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Print The Values of Multiple Checkboxes in VB6

29 New Member
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),mp f(column3),slid e(column4),pdc( column5),tgas(c olumn6),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 1377

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

Similar topics

6
3443
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 values to a field in the way that you can, for example, in a drop down field? Thanks in advance for any suggestions. With regards
3
4355
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 is to be filled out online, but I can imagine, for example, one of our members giving a talk and printing a pile of application forms to hand out to the audience. I am trying to add some specific styles in the print stylesheet so the forms...
0
1375
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 updated on the "on current" event that pulls the data from an underlying table. When I open the form, everything looks great, but when I do print preview (and/or print) the checkboxes in 3 of the option groups are all unchecked. When I cancel print...
29
3154
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. Does each checkbox name have to be unique? I was hoping to just group them under one name, and select from that array. PHP is not my native language - I'm coming at this from Perl, so bear with me, things are a little different in that country.
5
4195
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 presses delete. When delete is pressed, I want to go to a next page and run a sql command for every single box thats checked. The checkboxes store a value, and multiple boxes can be checked.
1
1510
by: prash.marne | last post by:
hi , i am having a simple form ----------------------------------------------------------------------- ----------------------------------------------------------------------- -------------- <form action="submit.php" method="POST"> <select name="activity" onchange="if(this.options.value=='M')
9
10414
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 DataGridViewtextBoxColumns. In each case the properties of the CheckBoxcolumn have been set to not allow nulls, so presumably only explicit true or false values should be possible. I run the application and set check boxes for DataGridView rows I am...
10
4485
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 the first time the user submits. However when user submits a second time while changing some of the selected boxes the page only re-submits the previosly selected checkbox values. It's like its storing it somewhere in the cache or something. My...
5
7039
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 comfortably getting entered into the database but the real problem is with the checkboxes..only one entry is being stored ...but i want to enter the multiple entries from the checkboxes to enter into the database...the form is a voting poll..and i...
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.