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,924 questions

51,857 answers

573 users

How to get the first N characters of a string in VB.NET

1 Answer

0 votes
Imports System
 
Public Class Test
    Public Shared Function get_first_n_characters(s As String, n As Integer) As String
        If (n >= s.Length) Then
            return s 
        End If
         
        return s.Substring(0, n)
    End Function
    Public Shared Sub Main()
        Dim s As String = "c++ c php vb.net java golang nodejs"
        Dim n As Integer = 7
         
        Dim first_n_ch As String = get_first_n_characters(s, n)
          
        Console.Write(first_n_ch)
    End Sub
End Class
 
 
 
 
' run:
'
' c++ c p
'

 



answered Feb 25, 2020 by avibootz

Related questions

1 answer 100 views
1 answer 106 views
1 answer 152 views
2 answers 154 views
1 answer 163 views
1 answer 141 views
1 answer 153 views
...