Newbie Question here

  • Thread starter Thread starter alxasa
  • Start date Start date
A

alxasa

Hi, just messing around and trying to get my feet wet with VB Express
and some code.... I've got this little program, and I am trying to
figure out how to call a function that is setup as a button (without
pressing the button, just run the function:

Somefunction()

If I just put that on a line by itself, it reads back 'declaration
expected'...... how do I run Somefunction() like a general call you
would have in javascript like <script>somejsfuntion();</script>, except
in VB???

-Angie
 
if you have a button called btnClickMe, you can call the click handler
by calling the following line of code:

btnClickMe.PerformClick
 
if you have a button called btnClickMe, you can call the click handler
by calling the following line of code:

btnClickMe.PerformClick

The preferred method is to have the button click event call another
function, eg:

private sub btnClickMe_Click(...)
DoClick()
End Sub

private sub DoClick()
'do stuff here
End sub

then just call DoClick whenever it is needed.

Michael
 
Michael said:
The preferred method is to have the button click event call another
function, eg:

private sub btnClickMe_Click(...)
DoClick()
End Sub

private sub DoClick()
'do stuff here
End sub

then just call DoClick whenever it is needed.

Michael

Ah, I see :), now so I have this all straight, if I just wanted to run
the DoClick() sub, how is it called properly? If there is a sub like
DoClick() and I want to run in the first part of the program, how would
that be setup?
 
If it's in a form, you could run it in the Form_Load event:

DoClick()

Robin S.
---------------------------------------------
 
Robin, sorry for my newbieness.... but could you please show which
steps/tabs, where and how you would place that?
 
I'm assuming that you have a form.

With the form open in design mode, double-click on
a gray area somewhere. It will bring you to the code-behind,
and add a Form_Load event.

In this procedure, put the call to the DoClick() method.
It will look like this if you click on the right thing.

Private Sub myForm_Load(ByVal sender as System.Object, _
ByVal e as System.EventArgs) Handles MyBase.Load
DoClick()
End Sub

The other thing you can do to create this event
is open your code-behind window, pull down "Form events"
on the left dropdown at the top, and pull down "Load"
on the right dropdown at the top.

Robin S.
 
By the way, if you're so new to VB.Net that you need help
putting code behind the form, you should race right out and
buy Tim Patrick's book, "Start to Finish VB2005". It's a
great book, and will really help you get up to speed fast.

Robin S.
 
RobinS said:
By the way, if you're so new to VB.Net that you need help
putting code behind the form, you should race right out and
buy Tim Patrick's book, "Start to Finish VB2005". It's a
great book, and will really help you get up to speed fast.

Robin S.

I am usually open source, but this project have me diving into all
sorts of new technologies :) Hopefully I can spin-up fast, and get
this done. I hope I am not bothering you to ask, but I am modifying a
program.... and it seems the .NET VB Express tool hides code and is
tricky to understand, but I am figuring it out :) Basically, I want to
completely turn off the form or GUI or have it not display at all, and
not appear the in the desktray/task manager --- is there a simple way
to accomplish all of these tasks? It's a security module, and it's
been handed down through generations in this company, has ugly
interface.... so I am in a pinch to tie this up tight. Thanks for your
time and info :)) Cheers! AmyMC
 
Alaxasas,

I never do it anymore as told in this thread, so therefore my method.

If you want to do a click event than I do.

TheClickEvent(me, nothing)

The bad thing from the btn.performclick is that the button has to be visible
at the moment you do that.

Creating extra methods has been for me never been a benefit.

Cor
 
I am usually open source, but this project have me diving into all
sorts of new technologies :) Hopefully I can spin-up fast, and get
this done. I hope I am not bothering you to ask, but I am modifying a
program.... and it seems the .NET VB Express tool hides code and is
tricky to understand, but I am figuring it out :) Basically, I want to
completely turn off the form or GUI or have it not display at all, and
not appear the in the desktray/task manager --- is there a simple way
to accomplish all of these tasks? It's a security module, and it's
been handed down through generations in this company, has ugly
interface.... so I am in a pinch to tie this up tight. Thanks for your
time and info :)) Cheers! AmyMC

You work for a company as a programmer and you're asking how to call a
function?

Michael
 
I am usually open source, but this project have me diving into all
sorts of new technologies :) Hopefully I can spin-up fast, and get
this done. I hope I am not bothering you to ask, but I am modifying a
program.... and it seems the .NET VB Express tool hides code and is
tricky to understand, but I am figuring it out :) Basically, I want to
completely turn off the form or GUI or have it not display at all, and
not appear the in the desktray/task manager --- is there a simple way
to accomplish all of these tasks? It's a security module, and it's
been handed down through generations in this company, has ugly
interface.... so I am in a pinch to tie this up tight. Thanks for your
time and info :)) Cheers! AmyMC

I don't know of a simple way to accomplish that. You
seem to want something that will run in the background,
but not show up in the task manager or the system tray.
The only way I know of to do that is to run as a Windows
service. I don't have any experience at that, so I can't
help you.

Anyone else have an idea how Alxasa can accomplish this?
Am I right that it has to be a windows service?

Robin S.
 
tricky to understand, but I am figuring it out :) Basically, I want to
completely turn off the form or GUI or have it not display at all, and
not appear the in the desktray/task manager --- is there a simple way
to accomplish all of these tasks?

To prevent it appear in the task-manager's PROCESSES list is something
I don't know. But preventing it from appearing in the taskbar and the
task-managers APPLICATIONS list is a common thing in Windows. In win32
world you do it with the WS_EX_TOOLWINDOW window style. I don't know
enough about VB to tell you how it exposes this style.
 
RobinS said:
I don't know of a simple way to accomplish that. You
seem to want something that will run in the background,
but not show up in the task manager or the system tray.
The only way I know of to do that is to run as a Windows
service. I don't have any experience at that, so I can't
help you.

Anyone else have an idea how Alxasa can accomplish this?
Am I right that it has to be a windows service?

Creating services in dot net is quite easy. A service is just an exe that
always runs (if set to autostart) whether users are logged on or not. If
this is what the OP wants then a service is appropriate. The taskbar icon
and services are not necessarily related. Generally when a service, such as
sqlserver, shows a taskbar icon it is a seperate exe that controls the
service and can be run or closed independant of the service.

Michael
 
Great, a half-way working option for me would be to somehow hide the
GUI, can that be done programatically? :) Thank you for your help
earlier, it did clear up my learning curve with VB.NET EXPRESS.
Someone in this thread actually asked me a loaded question about my
knowledge and position as a programmer? Thanks for not speeding
through my emails and responding like a true professional! :) Best
regards, A.
 
WS_EX_TOOLWINDOW - sounds like a start to what I want to do. Can
anyone expand on this from Lucian? :)
 
RobinS said:
Have you tried searching Google and/or MSDN?

Robin S.

:))) Not yet, but I did look up my question and didn't see any newbie
versions out there, but I will keep looking and hopefully someone on
here knows more than I do! ;) I hope I am smarter this time next year
with this dev. app. I am pretty good, but not with the syntax and
unique situations with Microsoft products.
 
Back
Top