Understand: Visual Basic and VB.NET are almost the same (the syntax is very similar), the difference is that VB.NET [Visual Basic .NET] works on the .NET Framework. You are requesting code for "Visual Basic 2010". Practically, this is it, this code will work in "Visual Basic 2008", "Visual Basic 2005", and even in "VS Express 2013 for Desktop" (which contains Visual Basic). Read the Visual Basic 6 / VB.NET / .NET Framework specification and definition. Again, better learn C # (also on the .NET Framework)!
The function itself:
Public Function RandomWord() ' Случайное число Dim rnd As New Random() ' Ваш массив: Dim massive() As String = {"lalka", "fsdfsd546", "heyt"} ' Случайное число, ограниченное количеством строк массива Dim random As Integer = rnd.Next(massive.Length) ' Вернуть результат: Return massive(random) End Function
Then use the function, the function returns a string:
Dim randomword As String = RandomWord()
And MessageBox.Show(randomword)
conclusion using MessageBox.Show(randomword)
, Console.WriteLine(randomword)
or other