| View previous topic :: View next topic |
| Author |
Message |
jdm Advanced Cheater
Reputation: 0
Joined: 19 Sep 2008 Posts: 88
|
Posted: Wed Feb 18, 2009 12:40 am Post subject: Code Converter For All VB and C# Programmers |
|
|
Hello all I thought this may be useful for all of those VB and C# programmers out their.
http://www.codechanger.com/
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Wed Feb 18, 2009 5:45 am Post subject: Re: Code Converter For All VB and C# Programmers |
|
|
I'm sorry but that it will work 100% without u haveing to change anything...
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
jdm Advanced Cheater
Reputation: 0
Joined: 19 Sep 2008 Posts: 88
|
Posted: Wed Feb 18, 2009 5:50 am Post subject: Re: Code Converter For All VB and C# Programmers |
|
|
| Naablet wrote: |
I'm sorry but that it will work 100% without u haveing to change anything... |
May you please re-word that as I could not understand what you are trying to say.
And all this is, is for people either learning C# or VB. For example:
If you found a program that had many features one may like and they obtained the source, all the have to do is copy & paste and their ya go.
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
|
| Back to top |
|
 |
jdm Advanced Cheater
Reputation: 0
Joined: 19 Sep 2008 Posts: 88
|
Posted: Wed Feb 18, 2009 2:31 pm Post subject: |
|
|
And to be honest I wouldn't know how well it converts from C# to VB simply because I use C#. But you are also right. It doesn't convert 100% but for one, to be a programmer you have to be somewhat intelligent. All you would have to do is think about what the errors are and just change it to make it work.
For example:
Here is a simple C# program that I got from a C# for dummies book(cd).
| Code: |
using System;
namespace DecimalBankAccount
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
double dDeposit = 123.454;
Console.WriteLine("Depositing {0:C}", dDeposit);
ba.Deposit(dDeposit);
Console.WriteLine("Account = {0}", ba.GetString());
double dAddition = 0.002;
Console.WriteLine("Adding {0:C}", dAddition);
ba.Deposit(dAddition);
Console.WriteLine("Resulting account= {0}", ba.GetString());
Console.WriteLine("Press Enter to terminate...");
}
}
public class BankAccount
{
private static int nNextAccountNumber = 1000;
private int nAccountNumber;
private decimal mBalance;
// Create - Bank Account
public void InitBankAccount()
{
nAccountNumber = ++nNextAccountNumber;
mBalance = 0;
}
// Create - Get Balance
public double GetBalance()
{
return (double)mBalance;
}
// Create - Get/Set Account Number
public int GetAccountNumber()
{
return nAccountNumber;
}
public void SetAccountNumber(int nAccountNumber)
{
this.nAccountNumber = nAccountNumber;
}
// Create - Deposit/Withdrawal
public void Deposit(double dAmount)
{
if (dAmount > 0.0)
{
decimal mTemp = (decimal)dAmount;
mTemp = Decimal.Round(mTemp, 2);
mBalance += mTemp;
}
}
public decimal Withdraw(decimal dWithdrawal)
{
if (mBalance <= dWithdrawal)
{
dWithdrawal = mBalance;
}
mBalance -= dWithdrawal;
return dWithdrawal;
}
// Create - Get String
public string GetString()
{
string s = String.Format("#{0} = {1:C}", GetAccountNumber(), GetBalance());
return s;
}
}
}
|
and when you convert it you get this:
| Code: |
Imports System
Namespace DecimalBankAccount
Public Class Program
Public Shared Sub Main(args As String())
Console.WriteLine("Create a bank account object")
Dim ba As New BankAccount()
ba.InitBankAccount()
Dim dDeposit As Double = 123.454
Console.WriteLine("Depositing {0:C}", dDeposit)
ba.Deposit(dDeposit)
Console.WriteLine("Account = {0}", ba.GetString())
Dim dAddition As Double = 0.002
Console.WriteLine("Adding {0:C}", dAddition)
ba.Deposit(dAddition)
Console.WriteLine("Resulting account= {0}", ba.GetString())
Console.WriteLine("Press Enter to terminate...")
End Sub
End Class
Public Class BankAccount
Private Shared nNextAccountNumber As Integer = 1000
Private nAccountNumber As Integer
Private mBalance As Decimal
' Create - Bank Account
Public Sub InitBankAccount()
nAccountNumber = System.Threading.Interlocked.Increment(nNextAccountNumber)
mBalance = 0
End Sub
' Create - Get Balance
Public Function GetBalance() As Double
Return DirectCast(mBalance, Double)
End Function
' Create - Get/Set Account Number
Public Function GetAccountNumber() As Integer
Return nAccountNumber
End Function
Public Sub SetAccountNumber(nAccountNumber As Integer)
Me.nAccountNumber = nAccountNumber
End Sub
' Create - Deposit/Withdrawal
Public Sub Deposit(dAmount As Double)
If dAmount > 0 Then
Dim mTemp As Decimal = DirectCast(dAmount, Decimal)
mTemp = [Decimal].Round(mTemp, 2)
mBalance += mTemp
End If
End Sub
Public Function Withdraw(dWithdrawal As Decimal) As Decimal
If mBalance <= dWithdrawal Then
dWithdrawal = mBalance
End If
mBalance -= dWithdrawal
Return dWithdrawal
End Function
' Create - Get String
Public Function GetString() As String
Dim s As String = [String].Format("#{0} = {1:C}", GetAccountNumber(), GetBalance())
Return s
End Function
End Class
End Namespace
|
And I get these two errors when trying to compile:
| Code: |
Error 1 Value of type 'Decimal' cannot be converted to 'Double'.
|
| Code: |
Error 2 Value of type 'Double' cannot be converted to 'Decimal'.
|
Now what do you think is that a decent conversion or a crappy one?
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Wed Feb 18, 2009 3:15 pm Post subject: |
|
|
| This is really neat.
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Wed Feb 18, 2009 4:13 pm Post subject: |
|
|
What will happen if u try to convert a inputbox to c#?
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Wed Feb 18, 2009 5:55 pm Post subject: |
|
|
| If you're a good programmer who's fluent in two languages, you should be able to convert the code between the two languages manually.
|
|
| Back to top |
|
 |
|