473,382 Members | 1,766 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,382 software developers and data experts.

VB to c# conversion...

Hello,

any volunteers to convert VB source code below to c#? I really would
appreciate that, because I wouldn't like to learn two new languages...
This function can be found from ExceleTel Inc www-site and is
copyrighted by the corresponding corporation. Unfortunately, they
didn't have c# version from this... Thx in advance!

Source:
-----------

Private Function IsVoiceModem() As Boolean
Dim ModemMediaModes As Integer
Dim VoiceModemMediaModes As Integer

' These are the minimal media modes expected for standard data
modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE +
LINEMEDIAMODE_DATAMODEM
' These are the minimal media modes expected for voice modems
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN + _
LINEMEDIAMODE_AUTOMATEDVOICE

' Check to see if the selected device is a modem and it is a voice
modem
If (InStr(1, etLine1.TAPITSP, "Modem", 1) 0) And _
((etLine1.DeviceMediaModesAvailable And VoiceModemMediaModes)
>= _
VoiceModemMediaModes) Then
IsVoiceModem = True
Else
IsVoiceModem = False
End If
End Function

Private Sub SetCompletion(ByVal Status As String)
Select Case CurrentPhoneNumber
Case 1
If TextCompletion1.Text = "" Then
TextCompletion1.Text = Status
End If
Case 2
If TextCompletion2.Text = "" Then
TextCompletion2.Text = Status
End If
Case 3
If TextCompletion3.Text = "" Then
TextCompletion3.Text = Status
End If
Case 4
If TextCompletion4.Text = "" Then
TextCompletion4.Text = Status
End If
Case 5
If TextCompletion5.Text = "" Then
TextCompletion5.Text = Status
End If
End Select
End Sub

May 24 '07 #1
4 1459
private bool IsVoiceModem()
{
int ModemMediaModes;
int VoiceModemMediaModes;

//These are the minimal media modes expected for standard
data modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE +
LINEMEDIAMODE_DATAMODEM;

//These are the minimal media modes expected for voice
modems
VoiceModemMediaModes = ModemMediaModes +
LINEMEDIAMODE_UNKNOWN + LINEMEDIAMODE_AUTOMATEDVOICE;

//Check to see if the selected device is a modem and it is
a voice modem

if(etLine1.TAPITSP.Contains("Modem")&&((etLine1.De viceMediaModesAvailable&VoiceModemMediaModes)>=Voi ceModemMediaModes))
IsVoiceModem = true;
else
IsVoiceModem = false;
}

private void SetCompletion(string Status)
{
switch (CurrentPhoneNumber)
{
case 1:
if (TextCompletion1.Text == "")
TextCompletion1.Text = Status;
break;
case 2:
if (TextCompletion2.Text == "")
TextCompletion2.Text = Status;
break;
case 3:
if (TextCompletion3.Text == "")
TextCompletion3.Text = Status;
break;
case 4:
if (TextCompletion4.Text == "")
TextCompletion4.Text = Status;
break;
case 5:
if (TextCompletion5.Text == "")
TextCompletion5.Text = Status;
break;
default:
break;
}
}

filia&sofia je napisao/la:
Hello,

any volunteers to convert VB source code below to c#? I really would
appreciate that, because I wouldn't like to learn two new languages...
This function can be found from ExceleTel Inc www-site and is
copyrighted by the corresponding corporation. Unfortunately, they
didn't have c# version from this... Thx in advance!

Source:
-----------

Private Function IsVoiceModem() As Boolean
Dim ModemMediaModes As Integer
Dim VoiceModemMediaModes As Integer

' These are the minimal media modes expected for standard data
modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE +
LINEMEDIAMODE_DATAMODEM
' These are the minimal media modes expected for voice modems
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN + _
LINEMEDIAMODE_AUTOMATEDVOICE

' Check to see if the selected device is a modem and it is a voice
modem
If (InStr(1, etLine1.TAPITSP, "Modem", 1) 0) And _
((etLine1.DeviceMediaModesAvailable And VoiceModemMediaModes)
= _
VoiceModemMediaModes) Then
IsVoiceModem = True
Else
IsVoiceModem = False
End If
End Function

Private Sub SetCompletion(ByVal Status As String)
Select Case CurrentPhoneNumber
Case 1
If TextCompletion1.Text = "" Then
TextCompletion1.Text = Status
End If
Case 2
If TextCompletion2.Text = "" Then
TextCompletion2.Text = Status
End If
Case 3
If TextCompletion3.Text = "" Then
TextCompletion3.Text = Status
End If
Case 4
If TextCompletion4.Text = "" Then
TextCompletion4.Text = Status
End If
Case 5
If TextCompletion5.Text = "" Then
TextCompletion5.Text = Status
End If
End Select
End Sub
May 24 '07 #2
"filia&sofia" <in*********@hotmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
any volunteers to convert VB source code below to c#?

A few messages back another poster asked a very similar question, and I
pointed out that several translation tools are publicly available on the
'net. For example, the code below is the result of translationg your sample
with http://www.developerfusion.co.uk/uti...btocsharp.aspx.
There is one thing that wil not immediately work in the translated code,
which is the call to "InStr". You can provide similar functionality in C# by
means of string.IndexOf, rather than importing the namespace
Microsoft.VisualBasic (which was probably implied in the original code but
was not visible in the sample). You will also want to replace the "&"
operator with "&&" (both are "AND" in VB).
private bool IsVoiceModem()
{
int ModemMediaModes;
int VoiceModemMediaModes;
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE + LINEMEDIAMODE_DATAMODEM;
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN +
LINEMEDIAMODE_AUTOMATEDVOICE;
if ((InStr(1, etLine1.TAPITSP, "Modem", 1) 0) &
((etLine1.DeviceMediaModesAvailable & VoiceModemMediaModes) >=
VoiceModemMediaModes)) {
IsVoiceModem = true;
} else {
IsVoiceModem = false;
}
}

private void SetCompletion(string Status)
{
if (CurrentPhoneNumber == 1) {
if (TextCompletion1.Text == "") {
TextCompletion1.Text = Status;
}
} else if (CurrentPhoneNumber == 2) {
if (TextCompletion2.Text == "") {
TextCompletion2.Text = Status;
}
} else if (CurrentPhoneNumber == 3) {
if (TextCompletion3.Text == "") {
TextCompletion3.Text = Status;
}
} else if (CurrentPhoneNumber == 4) {
if (TextCompletion4.Text == "") {
TextCompletion4.Text = Status;
}
} else if (CurrentPhoneNumber == 5) {
if (TextCompletion5.Text == "") {
TextCompletion5.Text = Status;
}
}
}

May 24 '07 #3
The problem with the above 2 conversions is that the implicit temp method
name variable remains (IsVoiceModem = true, etc.). You must use explicit
'return' statements in C#.

(The following is produced by Instant C#):
private bool IsVoiceModem()
{
bool tempIsVoiceModem = false;
int ModemMediaModes = 0;
int VoiceModemMediaModes = 0;

// These are the minimal media modes expected for standard data modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE + LINEMEDIAMODE_DATAMODEM;
// These are the minimal media modes expected for voice modems
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN +
LINEMEDIAMODE_AUTOMATEDVOICE;

// Check to see if the selected device is a modem and it is a voice modem
if (((etLine1.TAPITSP.ToUpper().IndexOf("Modem".ToUpp er(), 0) + 1) 0) &
((etLine1.DeviceMediaModesAvailable & VoiceModemMediaModes) >=
VoiceModemMediaModes))
{
tempIsVoiceModem = true;
}
else
{
tempIsVoiceModem = false;
}
return tempIsVoiceModem;
}

private void SetCompletion(string Status)
{
switch (CurrentPhoneNumber)
{
case 1:
if (TextCompletion1.Text == "")
{
TextCompletion1.Text = Status;
}
break;
case 2:
if (TextCompletion2.Text == "")
{
TextCompletion2.Text = Status;
}
break;
case 3:
if (TextCompletion3.Text == "")
{
TextCompletion3.Text = Status;
}
break;
case 4:
if (TextCompletion4.Text == "")
{
TextCompletion4.Text = Status;
}
break;
case 5:
if (TextCompletion5.Text == "")
{
TextCompletion5.Text = Status;
}
break;
}
}

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI
"filia&sofia" wrote:
Hello,

any volunteers to convert VB source code below to c#? I really would
appreciate that, because I wouldn't like to learn two new languages...
This function can be found from ExceleTel Inc www-site and is
copyrighted by the corresponding corporation. Unfortunately, they
didn't have c# version from this... Thx in advance!

Source:
-----------

Private Function IsVoiceModem() As Boolean
Dim ModemMediaModes As Integer
Dim VoiceModemMediaModes As Integer

' These are the minimal media modes expected for standard data
modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE +
LINEMEDIAMODE_DATAMODEM
' These are the minimal media modes expected for voice modems
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN + _
LINEMEDIAMODE_AUTOMATEDVOICE

' Check to see if the selected device is a modem and it is a voice
modem
If (InStr(1, etLine1.TAPITSP, "Modem", 1) 0) And _
((etLine1.DeviceMediaModesAvailable And VoiceModemMediaModes)
= _
VoiceModemMediaModes) Then
IsVoiceModem = True
Else
IsVoiceModem = False
End If
End Function

Private Sub SetCompletion(ByVal Status As String)
Select Case CurrentPhoneNumber
Case 1
If TextCompletion1.Text = "" Then
TextCompletion1.Text = Status
End If
Case 2
If TextCompletion2.Text = "" Then
TextCompletion2.Text = Status
End If
Case 3
If TextCompletion3.Text = "" Then
TextCompletion3.Text = Status
End If
Case 4
If TextCompletion4.Text = "" Then
TextCompletion4.Text = Status
End If
Case 5
If TextCompletion5.Text = "" Then
TextCompletion5.Text = Status
End If
End Select
End Sub

May 24 '07 #4
Create an additional VB project as a DLL library and put this function in
it. After you compile once, you can then use the function directly.

Mike Ober.

"filia&sofia" <in*********@hotmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
Hello,

any volunteers to convert VB source code below to c#? I really would
appreciate that, because I wouldn't like to learn two new languages...
This function can be found from ExceleTel Inc www-site and is
copyrighted by the corresponding corporation. Unfortunately, they
didn't have c# version from this... Thx in advance!

Source:
-----------

Private Function IsVoiceModem() As Boolean
Dim ModemMediaModes As Integer
Dim VoiceModemMediaModes As Integer

' These are the minimal media modes expected for standard data
modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE +
LINEMEDIAMODE_DATAMODEM
' These are the minimal media modes expected for voice modems
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN + _
LINEMEDIAMODE_AUTOMATEDVOICE

' Check to see if the selected device is a modem and it is a voice
modem
If (InStr(1, etLine1.TAPITSP, "Modem", 1) 0) And _
((etLine1.DeviceMediaModesAvailable And VoiceModemMediaModes)
>>= _
VoiceModemMediaModes) Then
IsVoiceModem = True
Else
IsVoiceModem = False
End If
End Function

Private Sub SetCompletion(ByVal Status As String)
Select Case CurrentPhoneNumber
Case 1
If TextCompletion1.Text = "" Then
TextCompletion1.Text = Status
End If
Case 2
If TextCompletion2.Text = "" Then
TextCompletion2.Text = Status
End If
Case 3
If TextCompletion3.Text = "" Then
TextCompletion3.Text = Status
End If
Case 4
If TextCompletion4.Text = "" Then
TextCompletion4.Text = Status
End If
Case 5
If TextCompletion5.Text = "" Then
TextCompletion5.Text = Status
End If
End Select
End Sub



May 24 '07 #5

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

Similar topics

1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
7
by: Michael Lehn | last post by:
Hi, I have a question regarding the conversion of objects. When is the conversion done by the constructor and when by the operator. My feeling tells me that the constructor is preferred. But...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
2
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public...
3
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
0
by: dataentryoffshore | last post by:
Get a Discount up to 60% on data entry, data capture, dataentry services, large volume data processing and data conversion services through offshore facilities in India. Offshore data entry also...
21
by: REH | last post by:
It it permissible to use the constructor style cast with primitives such as "unsigned long"? One of my compilers accepts this syntax, the other does not. The failing one chokes on the fact that the...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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.