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

VB6 Command button

104 100+
I have a command button in my application that writes to Excel for report purposes. It has many text boxes in VB app that it populates the Excel spreadsheet with. The problem is that VB gives an error on the volume lines of code against the one command button. It only allows a certain amount of code per button. Is there a way to overcome this issue or to trigger additional code outside that command button code?

Regards
Wernerh
Nov 13 '07 #1
4 2184
QVeen72
1,445 Expert 1GB
Hi,

As such there is no limitation for number of lines in a Sub procedure, but it can contain only 64K of code. If the procedure exceeds the limit, a compile-time error is generated.
Again there is no limitation on the number of procedures in a module, so you can break up one big procedure into smaller procedures and call them.

Regards
Veena
Nov 13 '07 #2
Wernerh
104 100+
Hi,

As such there is no limitation for number of lines in a Sub procedure, but it can contain only 64K of code. If the procedure exceeds the limit, a compile-time error is generated.
Again there is no limitation on the number of procedures in a module, so you can break up one big procedure into smaller procedures and call them.

Regards
Veena
Hi Veena
Yes, then my procedure is exceeding the 64k as you have stiplulated. Could you please give me an example of how to call a secondary procedure to follow on on the first procedure or direct me to literture that could assist. It would be appreciated.


Thanks
Werner
Nov 13 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

You have One Huge Procedure in Some Command_Click,
say,
Private Sub MyCmd_Click()

First Rename "MyCmd_Click" that to "MyProc1()"
After some 2000 Lines add an "End Sub"

Next Line add "Private Sub MyProc2()
Again After 2000 Lines add an End Sub

Repeat until you are finished with all the Lines..

And in actual Command Click event..

[code=vb]
Private Sub MyCmd_Click()
Call MyProc1
Call MyProc2
Call MyProc3
'.....
Call MyProc20
End Sub
[code]

Before doing anything, Keep a Back-Up of your Form ...

Regards
Veena
Nov 13 '07 #4
Wernerh
104 100+
Hi,

You have One Huge Procedure in Some Command_Click,
say,
Private Sub MyCmd_Click()

First Rename "MyCmd_Click" that to "MyProc1()"
After some 2000 Lines add an "End Sub"

Next Line add "Private Sub MyProc2()
Again After 2000 Lines add an End Sub

Repeat until you are finished with all the Lines..

And in actual Command Click event..

[code=vb]
Private Sub MyCmd_Click()
Call MyProc1
Call MyProc2
Call MyProc3
'.....
Call MyProc20
End Sub
[code]

Before doing anything, Keep a Back-Up of your Form ...

Regards
Veena

Thank you so much, just did it now and it works perfectly. Thanks again for the help

Werner
Nov 13 '07 #5

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

Similar topics

2
by: mksql | last post by:
New to Tkinter. Initially, I had some code that was executing button commands at creation, rather than waiting for user action. Some research here gave me a solution, but I am not sure why the...
2
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make....
8
by: dakman | last post by:
Recently, I have been needing to do this alot and I can never find a way around it, the main reason I want to do this is because for example in the application I am making right now, it creates a...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
9
by: Melissa | last post by:
What is the code to delete a command button from a form? Can the code be run from the click event of the button to be deleted? Thanks! Melissa
6
by: deko | last post by:
I have a several forms that accept user input in a textbox and then take some action based on that input after a command button is clicked. Is it possible issue the command when the user presses...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
4
by: Alex Chun | last post by:
How can I program a command button on a form to bring up the standard "Find and Replace" dialog on click? Separate but related: how do you run menu commands (e.g. "Edit" "Find") from VB? ...
4
by: John Smith | last post by:
I have a continuous form. there is a command button with the following code for the OnClick event: DoCmd.OpenForm "frmPlants", , , "PlantsID =" & Me!PlantsID I click the button and frmPlants...
3
by: kimiraikkonen | last post by:
Hi experts, I just want to ask a simple procedure of my simple form. My form has a input textbox and a button. I want this if you can help me: Application user types a command prompt command...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.