473,406 Members | 2,847 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,406 software developers and data experts.

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 1497

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

Similar topics

1
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
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
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
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
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
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...
4
by: Paul Rudin | last post by:
I can't get the gdb fringe interaction functionality to work with either pdb or pydb. Any hints as to versions or incantations I should try? I have the emacs22 from debian unstable...
51
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.