473,499 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interaction command and functions (tutorial)

Reason of this project:
The Microsoft.VisualBasic.Interaction class exposes many useful
commands and methods that were available in Visual Basic like
AppActivate, Beep, Callbyname...
This tutorial shows how to work with some of them.
Project details:
1- From VB 6.0 to VB .net 2.0
2- Useful interaction commands
3- Samples of interaction commands

1- From VB 6.0 to VB .net 2.0

There was several changes on VB .net (it's a big change and that's
clear). Although in an effort to make the transition from VB 6 to VB
2005 as easy as possible, Microsoft has gathered most of the Visual
Basic 6.0 commands and functions in the Microsoft.VisualBasic.dll
assembly.
Some of the commands and functions was deleted, other still the same
and others changed to the .net syntax.
For Example:
VbCrlf which is used on VB 6.0 (as a separator) still alive on VB .net
2.0 but a new syntax is already available for use.
ControlChars.crlf is the new method
As you are using VB .net I recommend that use the new syntax, and I'm
going to introduce some of the important change between the old and
the new syntax.

2- Useful interaction commands

VB 6.0 syntax contain many useful interaction commands and function
like the Message Box for example. Those commands still alive but have
been improved in the .net 2.0 version.

Shell Function:
The shell function runs an executable program, it works like the
command line so you can use it as a command line.
The shell function is capable of returning an integer indicating if
the program still running or not. The shell function was expanded in
the .net 2.0 version and supports an additional argument that enables
you to specify whether to wait until the shelled program terminates
with an optional timeout.
Use of the function

Shell (Application Path, Style, Wait, Timeout)

Example:

' Run Notepad.exe and wait until the user terminates it.
Shell ("notepad", AppWinStyle.NormalFocus, True)
AppActivate Function:
AppActivate is a cool function that may be helpful if you are
developing application for Windows. Now let see how this works and
what it do. The AppActivate function as it names, activate a currently
running application.
How it activates? Simply by giving the focus to the application
Window.
The function is quite useful and require only to know the windows
caption!
Use of the function

AppActivate ( Title) or AppActivate (ProcessID)

NB: You have to choose either to use the title or the processID and
not both!

Now let's see this example

' Activate the NotePad Window
AppActivate("Untitled - Notepad")

Now as we know those simple functions we can use them to build helpful
projects and application. Now see the sample of the interaction
commands.

3- Samples of interaction commands

This sample is exactly a direct (little expanded) application of the
two functions that we have studied together right now.
There's only one sample and if you run it you'll get a window with 2
buttons.
Each button introduce a sample for each function. The button caption
let you distinguish them.

The Shell sample:
Run a notepad application and return a message if the NotePad was
closed.
If the timeout was exceeded (5 seconds), return a message that the
NotePad still running
The AppActivate:
The following sample run a notepad with no focus and use AppActivate
to give it the focus.
So the sample use both of the functions

Download the source code
http://thedotnetsource.blogspot.com/...mands-and.html

The Zip file contains:
-The sample source code
-The readme.txt file
-The tutorial.txt file

Still have question:
Go to our blog (http://thedotnetsource.blogspot.com). Select the
tutorial post. Post a comment describing your problem.
If you have a general question, we highly recommend the MSDN Forums as
the best Dot Net forums in the net.
Jun 1 '08 #1
0 2115

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4063
by: Alex Cicco | last post by:
Hi, I am new to SQL. Please bear with me and allow me to ask a dumb question. I am debugging a stored procedure (written in Trans-SQL), and I found that the SQL analyzer that I use doesn't...
8
2033
by: Jasper | last post by:
I have a noob problem that is fairly expansive. Let me preface it by saying that I'm a beginning programmer and am using the game I'm writing as a learn-as-I-go tool. I'm trying to make a...
11
2716
by: Java and Swing | last post by:
Is there some other way, besides SWIG, which will allow me to call functions inside an Ansi C DLL? Example (C): defs.h ------- typedef unsigned long MY_DIGIT; myapp.c
6
1433
by: garyusenet | last post by:
I have created a new project. and within this project as per the tutorial created an sql database. i have made a query which returns the result i need. 1. I cant SAVE THE QUERY? where on earth...
1
2683
by: Crutcher | last post by:
I've been playing with dictionary subtypes for custom environments, and I encountered a strange interaction between exec, dictionary subtypes, and global variables. I've attached a test program,...
1
2361
by: Andrew McCall | last post by:
Hi Folks, I am building an application under multiple OS's, and I wanted to give my application For example, the test application I am working on is a calculator and I would like to have a...
51
4079
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
0
1201
by: Omar Abid | last post by:
Reason of this project: The Microsoft.VisualBasic.Interaction class exposes many useful commands and methods that were available in Visual Basic like AppActivate, Beep, Callbyname... This...
3
3927
by: mmm | last post by:
I am looking for advice on Python Editors and IDEs I have read other posts and threads on the subject and my two questions at this time are mainly about the IDLE-like F5-run facilities. While I...
0
7131
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
7007
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
7174
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,...
0
7220
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...
1
6894
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
7388
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...
0
4600
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...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.