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

Running VB subroutine from a button click...

4
I'm an old-school programmer (real old - Fortran, Pascal, etc.) who has not written any code in 15 years or so. I got the bright idea to learn VB (2008 Express). All has been going well and I'm at the tail end of writing a fairly complex program that includes some graphic routines. I think this is a simple question, and I'm just confused because of the VB terminology.

I have a graphic subroutine that I want to be able to call by clicking a button. The graphics routine works fine, and presents itself when I open the program. However, I need it to update as I change the data. VB will not let me call this routine. Here are the names of the two subs -

[Private Sub Do_The_Graph(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint]

[Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click]

The question is, how do I cause "Do_The_Graph" to execute when I click "Button_3"? Both routines reside in the same Class (and I don't fully understand that yet, either).

Thanks,
Nick.
Mar 17 '10 #1
11 3556
Guido Geurs
767 Expert 512MB
dear,

If I understand your problem I think the next code will do what you want:

Expand|Select|Wrap|Line Numbers
  1. [Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click]
  2.  
  3.     call Do_The_Graph(.....)
  4.  
  5.  
I hope this will help You.


br,
Mar 17 '10 #2
NPela
4
Thanks for your prompt reply.

I had tried the "Call" statement, but I get an error message that says "Argument not specified for parameter of 'e' of 'Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)'.

I've been going around in circles trying to determine what it needs for that 'e' parameter.

Nick
Mar 17 '10 #3
Guido Geurs
767 Expert 512MB
dear,

Is't possible to attach your files?

br,
Mar 17 '10 #4
Guido Geurs
767 Expert 512MB
dear,

Is the sub title OK ?

normal it's=

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3. End Sub
  4.  
br,
Mar 17 '10 #5
NPela
4
I can't attach the code for contractual reasons.

If I could just understand what the 'e' parameter is supposed to be, I might be OK.

Nick.
Mar 17 '10 #6
Guido Geurs
767 Expert 512MB
dear,

Ok, no problem, we will try it by common sense.

Q1: is the button a control not standard from MS VB6 ?
If it's standard : which Reference is loaded ??
If not, this is a control with his own var's !
Is it possible to say which OCX or so you are using ?.
In this case, you have to read the documentation of this control, in which I hope you will find an indication what the control is receiving and what are the dedicated var' to send to "Do_The_Graph";

it's even possible that the "e" is a dedicated var which consist of other var's !

br,
Mar 18 '10 #7
Guido Geurs
767 Expert 512MB
dear,

I have looked around and finally I'm fined out: this is VB.Net !
Sorry but I'm a VB6 programmer and not familiar with VB.net.
Maybe someone else can help you.

Sorry, br,
Mar 18 '10 #8
Guido Geurs
767 Expert 512MB
dear,

This is VB.net ! (Sorry, I'm a VB6 programmer with no experience on VB.net)
Maybe this will help:
If you Google to "ByVal e As System.Windows.Forms.PaintEventArgs" then you get Ms help on the topic. =>

http://msdn.microsoft.com/en-us/libr...eventargs.aspx

br,
Mar 18 '10 #9
NPela
4
Thanks for trying to assist. I will do some more digging. MicroSoft's tutorials are not very good... they either assume you know nothing or assume you know everything!

Nick.
Mar 18 '10 #10
Do_The_Graph is only called when the WM_PAINT message is requested (Form.Paint() event).

Been a while since I've done some VB but in .Net you should have a Me.Refresh() in any form controls, which should raise the Paint Event and that should call your function.
Mar 20 '10 #11
Hi, I have a question related to the above posts...

I'm trying to call a graphic subroutine from a separate button_click routine. Is this possible? I get the error message:

"Argument not specified for parameter 'e' of private sub ShowImage_Paint(sender as Object, e as System.Windows.Forms.PaintEventArgs)"

A partial list of code is:

Private Sub btnSpot1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpot1.Click
Call ShowImage_Paint()
End Sub

Private Sub ShowImage_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Create image.
Dim newImage As Image = Image.FromFile("C:\Users\Family\Pictures\Blue_Coun ter.jpg")
' Create Point for upper-left corner of image.
Dim ulCorner As New Point(470, 10)
' Draw image to screen.
e.Graphics.DrawImage(newImage, ulCorner)
End Sub

Any possible solutions would be greatly appreciated!

Chris
Oct 6 '10 #12

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

Similar topics

2
by: Chris | last post by:
Hi, Is it possible to start a subroutine in for example (frmMainForm) from another form (frmSubForm)? I want to start a subroutine called cmdButton1_Click. I wrote (in frmSubForm): ...
2
by: asadikhan | last post by:
Hi, I have a timer in javascript on my ASP.NET page. When the time expires (a point in my javascript code) I want to call a subroutine in my ASP.NET page. But I can't seem to figure out how to do...
3
by: ~J~ | last post by:
Hi everyone I'm positive this is possible, just never needed it until now and I don't have a clue where to start I have an XML document that is attached to an XSL style sheet, within this XSL...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
8
by: Patrick | last post by:
Hello - I'm working on a project to have 6 labels, each with a value of 0 - 9. Each label has a 2 buttons on the side, one labeled up, one labeled down. I want the up button to increment til it...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
4
by: Mark Lancaster | last post by:
I have a form that displays a time vs temperature graph when the user clicks a plot button. The plot is done in a picturebox using gr.drawline. I would like for this plot to be made without the...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
9
by: idorjee | last post by:
hi all, i've been trying, almost for the whole day, to submit the value of a variable in my perl script (eg, $sequence) to a subroutine in the same script when i click on a submit button. how can i...
9
by: petesquawk | last post by:
I need to make a subroutine run continuously in VB 2008. Can I make a button permanently on? If this is possible, how can I do this? I can put all of the subroutines I want run inside the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.