Convert C# to VB.NET

Thanks heres the source code link from google drive and this is video link from youtube.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NamesGenerator
{
    public partial class Form1 : Form
    {
        string[] FirstNames = { "John", "Peter", "Jason", "Andrew", "Richard" };
        string[] LastNames = { "Lannister", "Targaryen", "Snow", "Stark", "Mormont", "Tarly", "Greyjoy" };
        Random rand = new Random();

        public Form1()
        {
            InitializeComponent();
        }

        private void btn_Generate_Click(object sender, EventArgs e)
        {
            int indexFirstName = rand.Next(FirstNames.Length);
            int indexLastName = rand.Next(LastNames.Length);

            this.txtbox_FirstName.Text = FirstNames[indexFirstName];
            this.txtbox_LastName.Text = LastNames[indexLastName];
        }
    }
}

Open in new window



using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NamesGenerator
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

Open in new window

Rowel VirgoVisual Studio .NETAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
There are few websites which can help you in converting the code from C# to VB. You can use them as they are free.
1. http://converter.telerik.com/
2. http://www.developerfusion.com/tools/convert/csharp-to-vb/

VB.NET Code
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms

Namespace NamesGenerator
	Public Partial Class Form1
		Inherits Form
		Private FirstNames As String() = {"John", "Peter", "Jason", "Andrew", "Richard"}
		Private LastNames As String() = {"Lannister", "Targaryen", "Snow", "Stark", "Mormont", "Tarly", _
			"Greyjoy"}
		Private rand As New Random()

		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub btn_Generate_Click(sender As Object, e As EventArgs)
			Dim indexFirstName As Integer = rand.[Next](FirstNames.Length)
			Dim indexLastName As Integer = rand.[Next](LastNames.Length)

			Me.txtbox_FirstName.Text = FirstNames(indexFirstName)
			Me.txtbox_LastName.Text = LastNames(indexLastName)
		End Sub
	End Class
End Namespace

Open in new window


Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms

Namespace NamesGenerator
	NotInheritable Class Program
		Private Sub New()
		End Sub
		''' <summary>
		''' The main entry point for the application.
		''' </summary>
		<STAThread> _
		Private Shared Sub Main()
			Application.EnableVisualStyles()
			Application.SetCompatibleTextRenderingDefault(False)
			Application.Run(New Form1())
		End Sub
	End Class
End Namespace

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowel VirgoVisual Studio .NETAuthor Commented:
OK I will try this
Rowel VirgoVisual Studio .NETAuthor Commented:
site cannot convert it
Pawan KumarDatabase ExpertCommented:
Both runs fine. Which one you are facing issues with?
I have also given you the converted code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.