473,379 Members | 1,423 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,379 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 1185

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...
1
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: 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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.