RE: Array Type Mismatch
- From: State Troopers <StateTroopers@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 2 May 2006 07:54:02 -0700
I got the datatypes to work with eachother.
The function is now the problem.
I am getting "" for all the elements of my array.
thanks again.
-State
"Klatuu" wrote:
It appears you are trying to use string data types where parameter arrays.
are needed. Look in VBA Help and read up on Parameter Array. I think that
might give you some ideas on how to make your code work.
"State Troopers" wrote:
Heres the function:
-------------------------------------FUNCTION-------------------------------------
Function TextBoxGetLines(txtDone As TextBox, Optional KeepHardLineBreaks As
Boolean) As String()
Dim result() As String
Dim i As Long
' Activate soft line breaks. A soft line break is marked by the
' CR-Cr-LF sequence.
SendMessage txtDone.hwnd, EM_FMTLINES, True, ByVal 0&
' Retrieve all the lines in one operation and split results.
' This operation will leave trailing CR character for soft line breaks
only.
result() = Split(txtDone.Text, vbCrLf)
' We need a loop to trim the trailing CR character. If the second
' argument is true, we need to manually add a CR-LF pair to all
' the lines that don't contain such trailing CR char.
For i = 0 To UBound(result)
If Right$(result(i), 1) = vbCr Then
result(i) = Left$(result(i), Len(result(i)) - 1)
ElseIf KeepHardLineBreaks Then
result(i) = result(i) & vbCrLf
End If
Next
' Deactivate soft line breaks.
SendMessage txtDone.hwnd, EM_FMTLINES, False, ByVal 0&
TextBoxGetLines = result()
End Function
------------------------------------MAIN
CODE----------------------------------------
Dim strH As String
Dim strC As String
Dim strArray(6) As String
Dim i As Integer
txtInput.SetFocus
strH = txtInput.Text
strC = stripHTML(strH)
txtDone.SetFocus
txtDone.Text = strC
For i = 0 To UBound(strArray)
strArray(i) = TextBoxGetLines(txtDone, False)
Debug.Print i & " " & strArray(i)
Next
----------------------------------------EXPLANATION------------------------------------
The process is: I grab the source code from a website, then stip it of all
html tags. I am then left with 6 lines. the first is a blank line, and then 5
lines of text...this is for EVERY case.
I want to take those 6 lines, and store them into an array. From there, I
will validate whether the element contains text <> "" ....and then store the
elements in a table.
So far, I have everything except the storing of the elements in the array.
Thanks.
"Klatuu" wrote:
Not really enough here to really see the problem.
What error are you getting?
What does result() do?
I see you are passing a textbox object to TextBoxGetLines. First, it is
always best to fully qualify your object references. That way Access is less
likely to get confused. If txtDone is a control on your main form, I would
suggest you use Me.txtDone.
"State Troopers" wrote:
Hi.
I am having a problem with one of my functions.
here is the code:
strArray(i) = TextBoxGetLines(txtDone, False)
-------
Function TextBoxGetLines(tb As TextBox, Optional KeepHardLineBreaks As
Boolean) As String()
TextBoxGetLines = result()
End Function
Am I passing the variables into the function correctly?
Thanks.
-State
- References:
- RE: Array Type Mismatch
- From: State Troopers
- RE: Array Type Mismatch
- From: Klatuu
- RE: Array Type Mismatch
- Prev by Date: Re: Array Type Mismatch
- Next by Date: Re: Form vs. recordset
- Previous by thread: RE: Array Type Mismatch
- Next by thread: Form vs. recordset
- Index(es):
Relevant Pages
|