How to change these C# statements to VB.net

blurgal

Member
Joined
Sep 24, 2005
Messages
9
Programming Experience
Beginner
public string Username;
public string Password;
private void OkButton_Click(object sender, System.EventArgs e)
{
Username = UsernameTextBox.Text;
Password = PasswordTextBox.Text;
this.DialogResult = DialogResult.OK;
this.Hide();
}


if( credform.ShowDialog() == DialogResult.OK )
{

Credentials credform = new Credentials();
// Read the public properties on the Credentials form
Username = credform.Username;
Password = credform.Password;
SubmitButton.Enabled =
true;
}


CAn anyone tell me how to change these C# syntax to Vb.net plzzzzz. Help desperately needed. Thnx
 
Well... public string is Public as String...

so
Public UserName as string

private sub instead of private void....
no opening curly brackets...
close curlies get changed to End Sub and end if as needed

Only one = in the If statement and no () (actualy they are optional) and a "then" needs to be added to the line....
and... the if block has to do into a sub of some kind.

-tg
 
VB.NET:
Public UserName As String
Public Password As String

Private Sub OkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
   Username = UsernameTextBox.Text
   Password = PasswordTextBox.Text
   Me.DialogResult = DialogResult.OK
   Me.Hide()
End Sub
 
 
[SIZE=1][SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2]credform.ShowDialog() = DialogResult.OK Then
  [/SIZE][/SIZE]Dim credform As New Credentials[SIZE=1][SIZE=2][COLOR=#008000][SIZE=2]
  [/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Read the public properties on the Credentials form
  [/COLOR][/SIZE][SIZE=2]Username = credform.Username
  Password = credform.Password
  SubmitButton.Enabled = [/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2]
End If[/SIZE][/SIZE]
 
Use a Web-based code converter. There are a number around and I've linked to one below. I've also included a link to an article that describes how to create your own add-in for Visual Studio that will allow you to paste C# code into the IDE as its VB.NET equivalent as defined by your favourite Web-based converter, although I think it may only be for VS 2005.

C# to VB.NET converter
"Paste As..." add-in
 
Back
Top