ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the Val() function

Here, we are going to demonstrate the Val() function in VB.Net.
Submitted by Nidhi, on December 06, 2020

The Val() function is used to convert the numeric string into an integer number.

Syntax:

Val(str)

Parameters:

  • str: It is a specified numeric string.

Return Value:

The Val() function will return an integer value.

Program/Source Code:

The source code to demonstrate the Val() function is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the Val() function.
Module Module1
    Sub Main()
        Dim result As Integer = 0

        Dim n1 As String = "111"
        Dim n2 As String = "222"
        Dim n3 As String = "333"

        result = Val(n1)
        Console.WriteLine("Integer value: {0}", result)

        result = Val(n2)
        Console.WriteLine("Integer value: {0}", result)

        result = Val(n3)
        Console.WriteLine("Integer value: {0}", result)

    End Sub
End Module

Output:

Integer value: 111
Integer value: 222
Integer value: 333
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() method. In the Main() method, we created four variables result, n1, n2, and n3 that are initialized with 0, "111", "222", and "333".

result = Val(n1)
Console.WriteLine("Integer value: {0}", result)

result = Val(n2)
Console.WriteLine("Integer value: {0}", result)

result = Val(n3)
Console.WriteLine("Integer value: {0}", result)

In the above code, we converted the numeric string into an integer value, and then we printed them on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.