About VBVoice on .Net platform

Microsoft .NET technologies offer a wide variety of tools, services, clients and servers, which empower developers to build powerful applications. These technologies offer programmers far-reaching benefits. From accelerating and improving development, to providing advanced capabilities for deploying next-generation distributed applications, accessible from an array of mobile devices.

VBVoice has been supported on the Microsoft .NET platform since version 5.0.

With VBVoice you can take advantage of such .NET features as:

How does VB.NET differ from VB6?

Experienced VBVoice programmers will notice some important differences, discussed below.

Events Handlers

VBVoice Enter event is now named EnterEvent in the .NET environment, because Enter is a standard event for .NET components. Note that throughout the help files, the event is simply called Enter, but keep in mind the .NET name change.

The parameters passed to your event handling code are different. The first parameter is the Sender object, followed by an Event object specific to the event. The channel parameter can be retrieved from the Event object. For example, the EnterEvent handling in the Dial1 control may look like this:

EXAMPLE

VB.NET

Private Sub Dial1_EnterEvent(ByVal sender As Object, ByVal e As AxVBVoiceLib._DDialEvents_EnterEvent) Handles Dial1.EnterEvent

Dim ch As Integer
ch = e.channel 'retrieve the channel of the call
Dial1.NumToDial (ch) = "S3334444"'set a new number to dial

End Sub

C#

private void dial1_EnterEvent(object sender, AxVBVoiceLib._DDialEvents_EnterEvent e)
{

int ch;
ch = e.channel; //retrieve the channel of the call
dial1.NumToDial[ch] = "S3334444"; //set a new number to dial

}

IDE Changes

Add controls to a frame by selecting them in the toolbox and dragging-and-dropping on the frame. Simply clicking on the frame will also work.

The property pages can be viewed by clicking the icon on the control or clicking on Properties… at the bottom of the Properties window.

A project can have multiple frames, each of them sited on its own form and having a different name. Make sure not to use duplicate control names even if they are on different frames. Only one frame is allowed on a form.

Do not use multiple VBVoice projects in the same solution. VBVoice controls are global per process (Visual Studio IDE at design time) so it would create references to controls, which at runtime will belong to another process.

Use of VBVoice constants

VBVoice constants are defined in an assembly named VBVoiceLib. You must add a reference to VBVoiceLib.dll to your project and use the constants as in the example below.

EXAMPLE

VB.NET

Private Sub Dial1_Exit(ByVal sender As Object, ByVal e As AxVBVoiceLib._DDialEvents_ExitEvent) Handles Dial1.Exit

Dim ch As Integer
ch = e.channel
Dim callResult As VBVoiceLib.vbvCallResultConstants
callResult = Dial1.CallResult(ch)
'if busy go to a delay
If callResult = VBVoiceLib.vbvCallResultConstants.vbvBusy Then

Delay1.TakeCall(ch)

End If

End Sub

C#

private void playGreeting1_EnterEvent(object sender, AxVBVoiceLib._DPlayGreetingEvents_EnterEvent e)
{

int ch;
ch = e.channel;
VBVoiceLib.vbvCallResultConstants callResult;
callResult = dial1.CallResult[ch];
//if busy go to a delay

if (callResult == VBVoiceLib.vbvCallResultConstants.vbvBusy)
{

delay1.TakeCall(ch);

}

}

Greeting, Phrase, and Log objects

These objects are implemented by VBVoiceSupportLib in the Pronexus.VBVoice namespace. In order to use them, the former DLL must be added to the references of the project. For convenience, the namespace could be added to the project, using Imports Pronexus.VBVoice.

The code below displays a custom log on the Enter event of PlayGreeting and adds a custom phrase to the beginning of the greeting to be played:

VB.NET

Private Sub PlayGreeting1_EnterEvent(ByVal sender As System.Object, ByVal e As AxVBVoiceLib._DPlayGreetingEvents_EnterEvent) Handles PlayGreeting1.EnterEvent

Dim ch As Integer
ch = e.channel
Dim log As New VBVLog()
log.AddLogItem(ch, 0, "Enter event fired!")
Dim newPhrase As New Phrase()
'or Dim newPhrase As New Pronexus.VBVoice.Phrase()

newPhrase.CreateWavePhrase("C:\myWaveFiles\myWavefile.wav")
e.greeting.InsertPhrase(0, newPhrase)

End Sub

C#

using Pronexus.VBVoice;
...

private void playGreeting1_EnterEvent(object sender, AxVBVoiceLib._DPlayGreetingEvents_EnterEvent e)
{
int ch = e.channel; VBVLog log = new VBVLog();
log.AddLogItem(ch, 0, "Enter event fired!");
Greeting greet = e.greeting as Greeting;
Phrase myPhrase = new Phrase();
myPhrase.CreateWavePhrase(@"C:\myWaveFiles\myWaveFile.wav");
greet.InsertPhrase(0, newPhrase);
}

Packaging of VBVoice Components

VBVoice components belong to the Pronexus.VBVoice namespace and are implemented by VBVoiceDotnetInterface.dll. This assembly, along with the interop generated assemblies, is installed in the Global Assembly Cache (GAC) to be used by all VBVoice applications. Some of theses assemblies should be used to access objects not implemented by the interface assembly (e.g. Greeting, Phrase, Log).

Creating VBVoice Applications in .NET

A new blank solution or an existing solution without any VBVoice projects can be used. Follow the steps listed below to create a new VBVoice application.

  1. Add a new project to the solution:

    1. In the solution explorer, right click on your solution

    2. Click Add > New Project.

      • To use VB.NET to develop your application, highlight Visual Basic Projects, then click Windows Application in the Templates window

      • To use C#, highlight Visual C# Projects and click Windows Application in the Templates window

      • Alternative: Instead of starting with a blank solution, you can start the project with a VBVoice template, available for both C# and VB.NET.

    3. To use VB.NET to develop your application, highlight VBVoice Project in Visual Basic in the Templates pane.

    4. If you want to use C#, highlight VBVoice Project in C#.

    5. For VB.NET, you can select Visual Basic Projects folder and highlight VBVoice Project in the Templates pane.

    6. Accept or change the other settings. By clicking the OK button, .Net creates and saves a new project in the designated directory path, with a frame, a LineGroup control and an OnHook control in it.

    7. If VBVoice controls are not appearing on the toolbox, follow the previous step "Add the VBVoice controls to the tool box" to add them

  2. Start to create the application

    1. Add a VBVFrame control to the application's form.

    2. Adjust the frame to your desired size.

    3. Add controls to the VBVFrame.

    4. Continue to build your application as outlined in Building an Application.