Your technology certification is waiting. Enroll in Cloud Class ®
Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.
Public Function GetH(FindIn as Variant) as Variant
Dim myString as string
'If the value passed was NULL, then exit the function, returning NULL
if FindIn & "" = "" Then Exit Function
myString = FindIn
While instr(myString, "H") > 0
myString = Mid(MyString, instr(myString, "H"))
If Left(myString, 6) Like "H#####" Then
GetH = Left(myString, 6)
GetH = NULL
Open in new window
In this example I get the incorrect result
DH,Info. Employee# H83784
Function getid(A As Variant) As Variant
Dim i As Integer, C As String, D As String
getid = Null
If IsNull(A) Then Exit Function
For i = 1 To Len(A) - 5
C = Mid(A, i, 1)
If C = "H" Or C = "h" Then
D = Trim(Mid(A, i + 1, 5))
If Len(D) = 5 And IsNumeric(D) Then
getid = C & D
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.