VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Print a Selected portion of a Large Text File, Run any program as you like.

by Rajendra Shakya (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 30th September 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Print a Selected portion of a Large Text File, Run any program as you like.

Rate Print a Selected portion of a Large Text File, Run any program as you like.



   rtfdata.SelFontName = cmbfonts.Text
End Sub


Private Sub Command1_Click() ''Exit Button
    Unload Me
End Sub

Private Sub Command2_Click()   ''Print Button
    On Error Resume Next
   dlgopenfile.Flags = cdlPDReturnDC + cdlPDNoPageNums + cdlPDHidePrintToFile
   If rtfdata.SelLength = 0 Then
        MsgBox ("Selection Not Yet Made...")
   Else
      dlgopenfile.Flags = dlgopenfile.Flags + cdlPDSelection
   dlgopenfile.ShowPrinter
   rtfdata.SelPrint dlgopenfile.hDC
   
   End If

End Sub

Private Sub Command3_Click() ''Find Button
    On Error Resume Next
   Dim FoundPos As Double  'Integer
   Dim FoundLine As Double  'Integer
   FoundPos = rtfdata.Find(Text1.Text, 0, , rtfWholeWord)
    If Text1.Text = "" Then
        MsgBox ("Type a word to Search...")
        Text1.SetFocus
    Else
   If FoundPos <> -1 Then
      FoundLine = rtfdata.GetLineFromChar(FoundPos)
      rtfdata.SelStart = FoundPos - 470
      rtfdata.SelLength = 2770
   Else
      MsgBox "Word not found."
   End If
   End If
    FoundPos = -1
   rtfdata.SetFocus
End Sub

Private Sub Command4_Click()   'Back color button
    rtfdata.BackColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)

End Sub


Private Sub Command5_Click()  ''Calendar Button
    If Command5.Caption = "&Show Calendar" Then
        MonthView1.Visible = True
        Command5.Caption = "&Hide Calendar"
    Else
        MonthView1.Visible = False
        Command5.Caption = "&Show Calendar"
        

    End If
End Sub


Private Sub Command6_Click()  ''Clear Button
    If rtfdata.Text = "" Then
        rtfdata.LoadFile stropen
    Else
        rtfdata.Text = ""
    End If
End Sub

Private Sub Command7_Click() ''Run Program Button
    On Error Resume Next
   Dim stropen As String
   dlgopenfile.InitDir = "c:\winzip"
   dlgopenfile.FileName = "*.exe"
   dlgopenfile.ShowOpen
   stropen = dlgopenfile.FileName
    If Right$(stropen, 4) <> ".exe" Then
        MsgBox ("Please Select Program Files (*.exe)")
    End If
    Dim retval
    retval = Shell(stropen, 1)
End Sub

Private Sub fileopen_Click() ''File open Button
    On Error Resume Next
    
   cmbfonts.Visible = True
   Text1.Visible = True
   Dim stropen As String
   dlgopenfile.InitDir = "c:\"
      dlgopenfile.FileName = "*.*"
   dlgopenfile.ShowOpen
   stropen = dlgopenfile.FileName
    If Right$(stropen, 4) = ".exe" Or Right$(stropen, 4) = ".zip" Then
        MsgBox ("Please Select Text Files...")
    Else
       rtfdata.Visible = True
    Command2.Enabled = True
    Command3.Enabled = True
    Command4.Visible = True
    Command6.Visible = True
   rtfdata.LoadFile stropen, rtfText
   rtfdata.SetFocus
    
    End If

End Sub

Private Sub Form_load()
  Dim i As Integer
      For i = 0 To Screen.FontCount - 1
      cmbfonts.AddItem Screen.Fonts(i)  ''&&.Text
      Next
   cmbfonts.Visible = False
Randomize Timer
Me.BackColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)

Shape4.FillColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
Text1.ForeColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
Text1.BackColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
cmbfonts.ForeColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
cmbfonts.BackColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)  ''Text Box
    If KeyAscii = 13 Then
    On Error Resume Next
   Dim FoundPos As Double  'Integer
   Dim FoundLine As Double  'Integer
   FoundPos = rtfdata.Find(Text1.Text, 0, , rtfWholeWord)
    If Text1.Text = "" Then
        MsgBox ("Type a word to Search...")
        Text1.SetFocus
    Else
   If FoundPos <> -1 Then
      FoundLine = rtfdata.GetLineFromChar(FoundPos)
      rtfdata.SelStart = FoundPos - 470
    
      rtfdata.SelLength = 2770
   Else
      MsgBox "Word not found."
   End If
   End If
    FoundPos = -1
   rtfdata.SetFocus

   End If
End Sub

Private Sub Timer1_Timer()
    Me.Caption = Mid(Me.Caption, 1 + 1, Val(Len(Me.Caption) - 1)) & Mid(Me.Caption, 1, 1)
End Sub


Download this snippet    Add to My Saved Code

Print a Selected portion of a Large Text File, Run any program as you like. Comments

No comments have been posted about Print a Selected portion of a Large Text File, Run any program as you like.. Why not be the first to post a comment about Print a Selected portion of a Large Text File, Run any program as you like..

Post your comment

Subject:
Message:
0/1000 characters