Jump to content

load a file on an RTB

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
ravmonster

ravmonster

    Newbie

  • Members
  • PipPip
  • 18 posts
i'm trying to load a file from a listbox to a richtextbox(RTB)
but it's not working....
can any one help me....

here is my code:

Private Sub ListFiles(strPath As String, Optional Extention As String)
Dim File As String
If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
If Trim$(Extention) = "" Then
Extention = "*.*"
ElseIf Left$(Extention, 2) <> "*." Then
Extention = "*." & Extention
End If
          File = Dir$(strPath & Extention)
            Do While Len(File)
                List1.AddItem File
                File = Dir$
           Loop
  
      End Sub
Private Sub Command1_Click()
Dim theList As Long
Dim textToSearch As String
textToSearch = LCase(Text1.Text)
For theList = 0 To List1.ListCount - 1
    theListText = LCase(List1.List(theList))
    If theListText = textToSearch Then List1.Text = textToSearch
Next
    If textToSearch = List1.Text Then           '[B]the part here is not working[/B]
    rtftext.loadfile List1.Index
    End If
    
End Sub
      Private Sub Form_Load()
        ListFiles "C:\", "txt"
      End Sub
 

the code here list the file.txt from a directory
then the search button finds the file on that is typed on the textbox
and "i want to load the content of the file.txt but i couldn't do it"

i don't know how to load the file.....plz help me!!!!

#2
ravmonster

ravmonster

    Newbie

  • Members
  • PipPip
  • 18 posts
it seems that no one is interested to my post...???
is it because this thread is very easy to answer or because
members here hate people that is always asking question that is
very easy to answer....hehe!!


anyway...big thanks to the people here that is viewing this post...
thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Edited by ravmonster, 26 July 2009 - 06:43 AM.
wala lang


#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
We don't have a lot of VB coders on this forum. Looking at DreamInCode, it looks like they have more VB coders than we do. On the other hand, it appears that we have more C++ coders than they do. Generally, if you don't get an answer here, it's because we don't have the answer. It may be easy, but only if you know VB.

What was the solution?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
ravmonster

ravmonster

    Newbie

  • Members
  • PipPip
  • 18 posts
WingedPanther you are my idol..

thanks man..now i know how it's gonna be...

Edited by ravmonster, 26 July 2009 - 06:42 AM.
basta


#5
Guest_Kristian Finlay_*

Guest_Kristian Finlay_*
  • Guests
Check out this sample project at gotnetdot.com.It derives from Form and implements the owner drawing by handling the DrawItem event and MeasureItem event.You can also download a sample that implements an owner drawn listbox by deriving from ListBox and overriding the virtual methods OnDrawItem and OnMeasureItem. Here is a OnDrawItem override that draws colored rectangles in the listbox.
Coding:
protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
{
//undo the selection rect on the old selection
if( oldSelectedRect != e.Bounds &&
oldSelectedIndex > -1 && oldSelectedIndex < Items.Count)
{
e.Graphics.DrawRectangle(new Pen((Color) Items[oldSelectedIndex], oldSelectedRect);
}

//draw the item .. here we just fill a rect
if( e.Index > -1 && e.Index < Items.Count)
e.Graphics.FillRectangle(new SolidBrush( (Color)Items[e.Index] ), e.Bounds);

//draw selection rect if needed
if(SelectedIndex == e.Index)
{
e.Graphics.DrawRectangle(new Pen(Color.Black,2), e.Bounds);
oldSelectedRect = e.Bounds;
oldSelectedIndex = e.Index;
}
}

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Kristian, how was that relevant?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
ravmonster

ravmonster

    Newbie

  • Members
  • PipPip
  • 18 posts
yah!! how was that relevant?

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
You apparently forgot an End If. You have to use IIf to get the one-line deal to work.

   theListText = LCase(List1.List(theList))
    If theListText = textToSearch Then
        List1.Text = textToSearch
    End If
Next
    If textToSearch = List1.Text Then           'the part here is not working
    rtftext.loadfile List1.Index
    End If

sudo rm -rf /