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

51,852 answers

573 users

How to find the digit next to a given digit in a number with VB.NET

1 Answer

0 votes
Imports System

Class DigitFinder
    Public Shared Function FindNextDigit(ByVal number As Integer, ByVal target As Integer) As Integer
		Dim next_digit As Integer = -1

        While number > 0
            Dim current As Integer = number Mod 10
			
			number = number \ 10

            If current = target Then
                Return next_digit
            End If

            next_digit = current
        End While

        Return -1
    End Function

    Public Shared Sub Main()
        Dim number As Integer = 8902741
        Dim target As Integer = 2
        Dim result As Integer = FindNextDigit(number, target)

        If result <> -1 Then
            Console.WriteLine($"The digit after {target} in {number} is {result}.")
        Else
            Console.WriteLine($"The digit {target} is not found or has no next digit in {number}.")
        End If
    End Sub
End Class



' run
' 
' The digit after 2 in 8902741 is 7.
'

 



answered Oct 18, 2025 by avibootz
...