RE: Array Type Mismatch



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



.



Relevant Pages

  • RE: Follow up question. Get value of closed file.
    ... You havve to access each member of the array ... Dim ReturnData as Variant ... SourceSheet As String, _ ... Dim rsData As Object ...
    (microsoft.public.excel.programming)
  • Re: Need help with SeriesCollection Object Please !
    ... Why did you use 4 Elements in your Array and then the use of the Exit ... Function GetSourceSheet(sFmla As String, sWSname, sFile As String) As ... Dim i As Long ... ran my code on certain other charts sometimes it would return ...
    (microsoft.public.excel.programming)
  • Re: Searching for best matches in string query
    ... looped through my recordset as an array counting the matches. ... 'Receives an array to be searched and the string value containing all the ... Dim arrData() ' As String ... Dim iLeftcur, iRightCur, iPivot, iTemp As Long ...
    (microsoft.public.access.queries)
  • RE: ReDim Preserve code almost working
    ... specifying beginning and ending elements. ... SegList will, however, accept a zero-based array (because Option Base 1 does ... Optional iEnd As Long = -1) As String() ... Dim tmp() As String ...
    (microsoft.public.vb.general.discussion)
  • RE: Array Type Mismatch
    ... Function TextBoxGetLines(txtDone As TextBox, Optional KeepHardLineBreaks As ... Dim resultAs String ...
    (microsoft.public.access.formscoding)