Strung up 
Author Message
 Strung up

I have created a structure called HTMLText.

Public Structure HTMLText
    Private _InnerHTML As String
    Private _InnerText As String
    Public Sub New(ByVal myText As String)
        _InnerText = ""
        _InnerHTML = myText
        _InnerText = CleanHTML(myText)
    End Sub
    Public Function GetAbstractText(ByVal maxLenght As Integer) As String
        If maxLenght >= Me.InnerText.Length Or Me.InnerText = String.Empty
Then
            Return Me.InnerText
        Else
            Dim abstr As String = Me.InnerText.Substring(0, maxLenght)
            abstr = abstr.Substring(0, abstr.LastIndexOf(" "c)) + "..."
            Return abstr
        End If
    End Function
End Structure

But when I try to call it...

AbstractField.Text = CType(DesktopText.Text, HTMLText).GetAbstractText(100)
I get "Value of type 'String' cannot be converted to 'HTMLText'"

Any Ideas where im going wrong?... these are different namespaces but ive
imported HTMLText.
TIA
Chad



Sat, 17 Sep 2005 01:40:21 GMT  
 Strung up


Quote:
> I have created a structure called HTMLText.

> Public Structure HTMLText
>     Private _InnerHTML As String
>     Private _InnerText As String
>     Public Sub New(ByVal myText As String)
>         _InnerText = ""
>         _InnerHTML = myText
>         _InnerText = CleanHTML(myText)
>     End Sub
>     Public Function GetAbstractText(ByVal maxLenght As Integer) As String
>         If maxLenght >= Me.InnerText.Length Or Me.InnerText = String.Empty
> Then
>             Return Me.InnerText
>         Else
>             Dim abstr As String = Me.InnerText.Substring(0, maxLenght)
>             abstr = abstr.Substring(0, abstr.LastIndexOf(" "c)) + "..."
>             Return abstr
>         End If
>     End Function
> End Structure

> But when I try to call it...

> AbstractField.Text = CType(DesktopText.Text, HTMLText).GetAbstractText(100)
> I get "Value of type 'String' cannot be converted to 'HTMLText'"

> Any Ideas where im going wrong?... these are different namespaces but ive
> imported HTMLText.

You want to create a structure with the text from DesktopText, not cast
it.  Try:

dim ht As HTMLText = new HTMLText(DesktopText.Text)
AbstractField.Text = ht.GetAbstractText(100)

--
Patrick Steele
Microsoft .NET MVP
http://radio.weblogs.com/0110109



Sat, 17 Sep 2005 01:49:18 GMT  
 Strung up
OF COURSE!

Thanks.. dont know what i was thinking.

Chad



Quote:


> > I have created a structure called HTMLText.

> > Public Structure HTMLText
> >     Private _InnerHTML As String
> >     Private _InnerText As String
> >     Public Sub New(ByVal myText As String)
> >         _InnerText = ""
> >         _InnerHTML = myText
> >         _InnerText = CleanHTML(myText)
> >     End Sub
> >     Public Function GetAbstractText(ByVal maxLenght As Integer) As
String
> >         If maxLenght >= Me.InnerText.Length Or Me.InnerText =
String.Empty
> > Then
> >             Return Me.InnerText
> >         Else
> >             Dim abstr As String = Me.InnerText.Substring(0, maxLenght)
> >             abstr = abstr.Substring(0, abstr.LastIndexOf(" "c)) + "..."
> >             Return abstr
> >         End If
> >     End Function
> > End Structure

> > But when I try to call it...

> > AbstractField.Text = CType(DesktopText.Text,

HTMLText).GetAbstractText(100)

- Show quoted text -

Quote:
> > I get "Value of type 'String' cannot be converted to 'HTMLText'"

> > Any Ideas where im going wrong?... these are different namespaces but
ive
> > imported HTMLText.

> You want to create a structure with the text from DesktopText, not cast
> it.  Try:

> dim ht As HTMLText = new HTMLText(DesktopText.Text)
> AbstractField.Text = ht.GetAbstractText(100)

> --
> Patrick Steele
> Microsoft .NET MVP
> http://radio.weblogs.com/0110109



Sat, 17 Sep 2005 02:16:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dial Ups

2. Microsoft Press More Than 300 Titles + FREE UPS Ground shipping

3. Outlook Hang ups

4. Pop-ups in MS Office

5. Dial Ups

6. Default Dial Ups

7. Anyone worked with UPS Online Tools

8. SET UPS: Please Stop... AND Lood

9. VBA ups & downs

10. New UPS System 6-8 Hours Continuous Service

11. UPS Online Tools Using VB

12. vba ups & downs

 

 
Powered by phpBB® Forum Software