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

51,839 answers

573 users

How to find the last character that is repeated in a string with VB.NET

1 Answer

0 votes
Imports System
				
Public Module Module1
	Public Function get_last_character_repeated(s As String) As Integer
		Dim len As Integer = s.Length - 1
		Dim ch_idx As Integer = -1
           
		For i As Integer = 0 To len
			For j As Integer = i + 1 To len
				If (s(i) = s(j)) Then
                 	ch_idx = i
					Exit For
				End If
			Next
		Next
        return ch_idx
	End Function  
	Public Sub Main()
		Dim s As String = "abcdxypcbadom"
        
		Dim i As Integer = get_last_character_repeated(s)
		If (i = -1) Then
            Console.WriteLine("Not found")
        else
            Console.WriteLine(s(i))
		End If
	End Sub
End Module



' run:
'
' d
'

 



answered Jan 25, 2020 by avibootz

Related questions

...