Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by PeterBaileyUk
at 2024-07-25 02:43:55
Point:500 Replies:19 POST_ID:829099USER_ID:11868
Topic:
Microsoft Access Database;;
I have created an array by using the split function.
ClientWords = Split(Trim(txt))
I would like to do a redim preserve to add an extra element so I can mark a specific word in the array.
How do i do that
I tried ReDim Preserve ClientWords(UBound(ClientWords),0)
but i get subscript out of range
ClientWords = Split(Trim(txt))
I would like to do a redim preserve to add an extra element so I can mark a specific word in the array.
How do i do that
I tried ReDim Preserve ClientWords(UBound(ClientWords),0)
but i get subscript out of range
Expert: eenookami replied at 2024-07-29 17:35:02
Peter/Dale/Jell,
Thank you and appreciate you returning to the question to clarify it for Duncan's benefit.
eenookami
CS Moderator
Thank you and appreciate you returning to the question to clarify it for Duncan's benefit.
eenookami
CS Moderator
Author: PeterBaileyUk replied at 2024-07-28 09:35:44
It seems you all answered your own things, the solution provided by Jell at that time was the best solution, I believe I am always fair when dishing out points (I think fyed would agree) if I have two that work then I usually share but in this case Jell understood perfectly the requirement. Hence the full points. In fact I had already posted the first part hence I ignored the "range" it was the addition of the second array that completed the task.
Expert: Dale Fye (Access MVP) replied at 2024-07-28 06:40:14
Nope, Jell has a good working solution that works in Access VBA.
Expert: James Elliott replied at 2024-07-28 05:29:29
Maybe my interpretation of the question would help:
The OP wanted to be able to tag certain words in his one-dimensional array, created using the split function.
I provided a solution which copied the 1-d array to a 2-d array, so that he could place a tag (in the second dimension) next to each word if he wished to.
The OP wanted to be able to tag certain words in his one-dimensional array, created using the split function.
I provided a solution which copied the 1-d array to a 2-d array, so that he could place a tag (in the second dimension) next to each word if he wished to.
Expert: eenookami replied at 2024-07-28 05:21:16
PeterBaileyUk,
Duncanb7 has asked for clarification of the solution. It would seem he is not the only one.
Experts, it's there any reason to change the points distribution here? Please advise.
eenookami
CS Moderator
Duncanb7 has asked for clarification of the solution. It would seem he is not the only one.
Experts, it's there any reason to change the points distribution here? Please advise.
eenookami
CS Moderator
Expert: Dale Fye (Access MVP) replied at 2024-07-25 04:22:27
jell,
nothing. I focused in on "Range". After I posted the comment I realized you had basically recommended the same thing that I did, use a second array.
nothing. I focused in on "Range". After I posted the comment I realized you had basically recommended the same thing that I did, use a second array.
Expert: James Elliott replied at 2024-07-25 04:08:42
fyed,
what, aside from my testing my code in Excel and forgetting to take out the 'range' reference, makes it an "Excel" solution?
what, aside from my testing my code in Excel and forgetting to take out the 'range' reference, makes it an "Excel" solution?
Expert: duncanb7 replied at 2024-07-25 04:02:46
Dear Author,
from your post , it seems you want add one more cell into array.
but you want multi-dimension array,
Thanks for your reply
Duncan
I would like to do a redim preserve to add an extra element so I can mark a specific word in the array
from your post , it seems you want add one more cell into array.
but you want multi-dimension array,
Thanks for your reply
Duncan
Expert: Dale Fye (Access MVP) replied at 2024-07-25 03:58:50
Peter,
I'm confused. You posted to an Access topic area, yet accepted an Excel solution?
I'm confused. You posted to an Access topic area, yet accepted an Excel solution?
Expert: Dale Fye (Access MVP) replied at 2024-07-25 03:56:34
I don't believe you can use redim to change the number of dimensions in an array.
You could write your own code to do this with a 2 dimensional array
Dim xWords() As String
Dim ClientWords() As Variant
xWords = Split("Your text string goes here")
ReDim ClientWords(UBound(xWords), 1)
For x = LBound(xWords) To UBound(xWords)
ClientWords(x, 0) = xWords(x)
Next
You could write your own code to do this with a 2 dimensional array
Dim xWords() As String
Dim ClientWords() As Variant
xWords = Split("Your text string goes here")
ReDim ClientWords(UBound(xWords), 1)
For x = LBound(xWords) To UBound(xWords)
ClientWords(x, 0) = xWords(x)
Next
Expert: duncanb7 replied at 2024-07-25 03:41:23
Dear Author,
Is the code matched to your question post?
Please advise
Duncan
Is the code matched to your question post?
Please advise
Duncan
Author: PeterBaileyUk replied at 2024-07-25 03:38:25
thank you
Author: PeterBaileyUk replied at 2024-07-25 03:34:41
our responses are crossing just seen 40219078
Author: PeterBaileyUk replied at 2024-07-25 03:33:49
I must have said it wrong the split creates the array fine I need to add another dimension so I can flag them
Accepted Solution
Expert: James Elliott replied at 2024-07-25 03:32:23
500 points EXCELLENT
See if this helps at all:
Sub SplitWithTag()Dim arr As VariantDim arrTag As VariantDim x As Longarr = Split(Range("A1"))ReDim arrTag(UBound(arr), 1)For x = LBound(arr) To UBound(arr) arrTag(x, 0) = arr(x) arrTag(x, 1) = "Your tag"Next xEnd Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:
Expert: duncanb7 replied at 2024-07-25 03:26:28
try this with UBound
Sub Test()Dim ClientWords() As StringClientWords() = Split("How are you")Debug.Print UBound(ClientWords, 1)ReDim Preserve ClientWords(UBound(ClientWords, 1) + 1)Debug.Print UBound(ClientWords, 1)ClientWords(UBound(ClientWords, 1)) = "Today"Debug.Print ClientWords(UBound(ClientWords, 1))End Sub 1:2:3:4:5:6:7:8:9:
Author: PeterBaileyUk replied at 2024-07-25 03:26:05
heres my code so far its just a question of tagging i thought adding an extra element would allow that
ClientWords = Split(Trim(txt)) For x = LBound(ClientWords) To UBound(ClientWords) Step 1 With rstWordExceptions .MoveFirst 'cycle through the query grabbing strings Do Until .EOF If ClientWords(x) = rstWordExceptions.Fields("sdesc").Value Then Else End If rstWordExceptions.MoveNext Loop End With Next x 'loop to next word in array 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:
Author: PeterBaileyUk replied at 2024-07-25 03:24:49
vba gives compile error method or data member not found on counta
I have
207
s16
1.6
[120]
I want it to go through a record set and if it finds the current word clientwords(1) s16 in this case it will tag 16 so i can use that later.
I have
207
s16
1.6
[120]
I want it to go through a record set and if it finds the current word clientwords(1) s16 in this case it will tag 16 so i can use that later.
Expert: duncanb7 replied at 2024-07-25 03:15:46
Is it what you want for redim ?
Hope understand your question.If not, pls pt it out
Duncan
Hope understand your question.If not, pls pt it out
Duncan
Sub Test()Dim ClientWords() As StringClientWords() = Split("How are you")'Debug.Print ClientWords(1)ReDim Preserve ClientWords(Application.CountA(ClientWords))ClientWords(Application.CountA(ClientWords) - 1) = "Today"Debug.Print ClientWords(3)End Sub 1:2:3:4:5:6:7:8: