AccessVBANewbie
Registered User.
- Local time
- Today, 08:08
- Joined
- Jan 23, 2014
- Messages
- 19
First of all apologies for restarting this post as the previous one I did not explain myself properly. I hope I have done a better job now. I would appreciate anyone who could spare their time to have a look at this issue I am having. Please let me know if you need any further clarifications. Thank you very much.
L=Letter , X=number. Examples consisting of three parts (it can be more than three).
1. LLLLXXXXXX_LLLLXXXXXX_LLLLXXXXXX
OR
2. LLLLXXXXXX LLLLXXXXXX LLLLXXXXXX
OR
3. LLLLXXXXXX&LLLLXXXXXX&LLLLXXXXXX
OR
4. LLLL_LLLLXXXXXX&LLLLXXXXXX
OR
5. LL LLLLXXXXXX&LLLLXXXXXX
I would like to develop a function that takes a string that is made up of three parts or more and each part is separated by an underscore “_”, space, or “&”. There is no character that takes precedence over the other. It will always be only a single character which seperates the parts.
The check will always be done from the left. It should carry out the following actions:
1. Display all characters from the left until it reaches the first seperator “_” underscore OR “space” or “&”
2. Check only Part1 if it is made up of 4 letters and the rest 6 numbers (see 1-3 above). If that is the case only return part 1.
3. If part one only has letters and no numbers (see above 4-5) return all parts. Part one can consist of two letters or more.
I have started the function for step 1 above that searches for the character “_” underscore and display all characters until the first “_” is reached. I would like to include the same for “Space” or “&” in this function.
Once that is done I would like to do step 2 and step 3.
Situation 1:
LLLLXXXXXX_LLLLXXXXXX_LLLLXXXXXX
Answer1: LLLLXXXXXX
Situation 2:
LLLLXXXXXX LLLLXXXXXX&LLLLXXXXXX
Answer2: LLLLXXXXXX
Situation 3:
LLLLLLLLLLLLL_LLLLXXXXXX&LLLLXXXXXX
Or
LL&LLLLXXXXXX_LLLLXXXXXX
OR
LL LLLLXXXXXX LLLLXXXXXX
OR
LLLL
Answer3:
Full name with all parts should be returned for all above four cases under situation 3.
L=Letter , X=number. Examples consisting of three parts (it can be more than three).
1. LLLLXXXXXX_LLLLXXXXXX_LLLLXXXXXX
OR
2. LLLLXXXXXX LLLLXXXXXX LLLLXXXXXX
OR
3. LLLLXXXXXX&LLLLXXXXXX&LLLLXXXXXX
OR
4. LLLL_LLLLXXXXXX&LLLLXXXXXX
OR
5. LL LLLLXXXXXX&LLLLXXXXXX
I would like to develop a function that takes a string that is made up of three parts or more and each part is separated by an underscore “_”, space, or “&”. There is no character that takes precedence over the other. It will always be only a single character which seperates the parts.
The check will always be done from the left. It should carry out the following actions:
1. Display all characters from the left until it reaches the first seperator “_” underscore OR “space” or “&”
2. Check only Part1 if it is made up of 4 letters and the rest 6 numbers (see 1-3 above). If that is the case only return part 1.
3. If part one only has letters and no numbers (see above 4-5) return all parts. Part one can consist of two letters or more.
I have started the function for step 1 above that searches for the character “_” underscore and display all characters until the first “_” is reached. I would like to include the same for “Space” or “&” in this function.
Once that is done I would like to do step 2 and step 3.
Code:
[COLOR=black][FONT=Verdana][SIZE=3][FONT=Calibri]Function SearchforChar(strTest As String) As String[/FONT][/SIZE][/FONT][/COLOR]
[FONT=Verdana][COLOR=black][SIZE=3][FONT=Calibri]Dim test2 As String[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Calibri]Dim strUntil As String[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Calibri]strUntil = "_" [/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Calibri]test2 = Left(strTest, InStr(1, strTest, strUntil) - 1)[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Calibri]SearchforChar = test2[/FONT][/SIZE][/COLOR]
[COLOR=black][FONT=Calibri][SIZE=3]End Function[/SIZE][/FONT][/COLOR]
[/FONT]
Situation 1:
LLLLXXXXXX_LLLLXXXXXX_LLLLXXXXXX
Answer1: LLLLXXXXXX
Situation 2:
LLLLXXXXXX LLLLXXXXXX&LLLLXXXXXX
Answer2: LLLLXXXXXX
Situation 3:
LLLLLLLLLLLLL_LLLLXXXXXX&LLLLXXXXXX
Or
LL&LLLLXXXXXX_LLLLXXXXXX
OR
LL LLLLXXXXXX LLLLXXXXXX
OR
LLLL
Answer3:
Full name with all parts should be returned for all above four cases under situation 3.