Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Get the longest numeric value in string
Author:
Francisco
Submitted:
8/7/2012
Version:
VB 2010
Compatibility:
VB6, VB 2005, VB 2008, VB 2010
Category:
String Manipulation
Views:
6904
This function returns the longest numeric value in a string. Example msgbox trimStrNum("qwertyuiop3332-4-22_bb*·%") This will display a msgbox with "3332".
Declarations:
'none
Code:
' this function returns the longest number in a string Private Function trimStrNum(ByVal strVal As String) As String Dim i As Integer Dim strTmp() As String Dim chrTmp As String On Error Resume Next For i = 1 To Len(strVal) chrTmp = Mid(strVal, i, 1) If Not IsNumeric(chrTmp) Then strVal = Replace(strVal, chrTmp, " ") End If Next strTmp = Split(strVal, " ") For i = 0 To UBound(strTmp) - 1 If Len(trimStrNum2) < Len(strTmp(i + 1)) Then trimStrNum2 = strTmp(i + 1) End If Next End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement