Extract characters from a string

  • Thread starter Thread starter edouardlo
  • Start date Start date
E

edouardlo

I would like to extract characters from a string field. I tried this
function: left(info, 2), the extracted character would be "in".
However, info is actually a field name which contants 1A_Peter. What
I want to extract is 1A instead.
How can I solve this problem?
THX ~
 
I would like to extract characters from a string field. I tried this
function: left(info, 2), the extracted character would be "in".
However, info is actually a field name which contants 1A_Peter. What
I want to extract is 1A instead.
How can I solve this problem?
THX ~
Hi, try use:

In Modules write this code:
Function Extractstring(ByVal InString As String) As String
If InStr(InString, "_") <> 0 Then
Extract1 = Left(InString, Len(InString) - InStr(InString, "_") -
1)
Else: Extractstring = InString
End If
End Function

In controlsource of textbox use: = Extractstring([info])

HTH
Luan
 
On Jul 30, 1:51 pm, (e-mail address removed) wrote:> I would like to extract characters from a string field. I tried this
function: left(info, 2), the extracted character would be "in".
However, info is actually a field name which contants 1A_Peter. What
I want to extract is 1A instead.
How can I solve this problem?
THX ~

Hi, try use:

In Modules write this code:
Function Extractstring(ByVal InString As String) As String
If InStr(InString, "_") <> 0 Then
Extract1 = Left(InString, Len(InString) - InStr(InString, "_") -
1)
Else: Extractstring = InString
End If
End Function

In controlsource of textbox use: = Extractstring([info])

HTH
Luan

Hi, sorry there is typing mistake:

Function Extractstring(ByVal InString As String) As String
If InStr(InString, "_") <> 0 Then
Extractstring = Left(InString, Len(InString) - InStr(InString,
"_") - 1)
Else: Extractstring = InString
End If
End Function

;-)
Luan
 
Back
Top