On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Public Function MyFunction(ByVal A As String, ByVal B as String) As String
' Dim A as double
Dim intNumber as double
If Integer.TryParse(A, intNumber) > Integer.TryParse(B, intNumber)
Return A + "is larger than B"
Else
Return B + "is larger than A"
End if
End Function
Thanks.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Public Function MyFunction(ByVal A As String, ByVal B as String) As String
If Conversions.ToInteger(A) > Conversions.ToInteger(B) Then
Return A & " is larger than " & B
Else
Return B & " is larger than " & A
End if
End Function
Public Function MyFunction(ByVal A As String, ByVal B as String) As String
'' You need two versions of intNumber one for A and the other for B
'' Otherwise B will overwrite A
Dim intNumberA As Double
Dim intNumberB As Double
If Double.TryParse(A, intNumberA) > Double.TryParse(B, intNumberB)
Return A + " is larger than B"
Else
Return B + " is larger than A"
End if
End Function
Public Function MyFunction(ByVal A As String, ByVal B as String) As String
'' You need two versions of intNumber one for A and the other for B
'' Otherwise B will overwrite A
Dim intNumberA As Double
Dim intNumberB As Double
'' Convert values from the string
Double.TryParse(A, intNumberA)
Double.TryParse(B, intNumberB)
'' Use the Math.Max Library function to find the larger of the two
Dim maxValue = Math.Max(intNumberA, intNumberb)
'' See which was the larger and return the correct message
If maxValue = intNumberA
Return A + " is larger than B"
Else
Return B + " is larger than A"
End If
End Function
Imports Microsoft.VisualBasic.CompilerServices
Public Function MyFunction(ByVal A As String, ByVal B As String) As String
' Parse / validate input.
'
Dim numberA As Double
Dim numberB As Double
If Not Double.TryParse(A, numberA) Then
Return A & " is not a valid number."
End If
If Not Double.TryParse(B, numberB) Then
Return B & " is not a valid number."
End If
' Compare values.
'
If numberA > numberB Then
Return A & " is larger than " & B
ElseIf numberB > numberA Then
Return B & " is larger than " & A
Else
Return A & " is equal to " & B
End If
End Function
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.