Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,955 questions

51,897 answers

573 users

How to get the second word of a string in VB.NET

3 Answers

0 votes
Imports System

Public Class GetTheSecondWordOfString_VB_NET
	Public Shared Sub Main()
		Dim str As String = "c java c# python c++ vb.net rust"
        Dim words As String() = str.Split(" "c)

        If words.Length > 1 Then
            Dim secondWord As String = words(1)
            Console.WriteLine("The second word is: " & secondWord)
        Else
            Console.WriteLine("The input string does not contain enough words.")
        End If
    End Sub
End Class


' run:
'
' The second word is: java
'

 



answered Oct 3, 2024 by avibootz
edited Oct 3, 2024 by avibootz
0 votes
Imports System
Imports System.Linq

Public Class Program
	Public Shared Sub Main()
		Dim str As String = "c java c# python c++ vb.net rust"
		
        Dim secondWord As String = str.Split(" "c).Skip(1).FirstOrDefault()
		
        Console.WriteLine(secondWord)
    End Sub
End Class



' run:
'
' java
'

 



answered Oct 3, 2024 by avibootz
0 votes
Imports System

Public Class Program
	Public Shared Sub Main()
		Dim str As String = "c java c# python c++ vb.net rust"
		
        Dim secondWord As String = str.Split(" "c)(1)
		
        Console.WriteLine(secondWord)
    End Sub
End Class



' run:
'
' java
'

 



answered Oct 3, 2024 by avibootz

Related questions

1 answer 93 views
1 answer 167 views
1 answer 108 views
2 answers 165 views
1 answer 112 views
1 answer 131 views
...