Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
| Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2004, 02:07 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default can't open txt file by clicking icon for it


i have built a text editor, and it works good, and i have set it to be the default program for opening text files. but when i click on a text file, it opens my text editor, but with no text. i have to open the text file after my text editor is already open? here is my code so far;

************************************************** ********
Private Sub Command1_Click()
CommonDialog1.Filter = "Text Files (*.txt)|*.txt|HTML|*.HTML|All Files|*.*"
CommonDialog1.InitDir = "X:\"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Output As 1
Print #1, Text1.Text
Close 1
End If
End Sub

Private Sub Command2_Click()

CommonDialog1.Filter = "Text Files (*.txt)|*.txt|HTML|*.HTML|All Files|*.*"
CommonDialog1.InitDir = "X:\"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Text1.Text = ""
Dim strPath As String
Dim strText As String
strPath = CommonDialog1.FileName

n = Chr(13) + Chr(10) ' this is a charater return
Open strPath For Input As 1
Do Until EOF(1)
Line Input #1, strText
Text1.Text = Text1.Text & strText & n
Loop
Close #1
End If

End Sub

Private Sub Command3_Click()

If Text1.Text <> "" Then
REPLY = MsgBox("ERASE ALL TEXT AND START NEW?", vbYesNo)
If REPLY = vbYes Then Text1.Text = ""
End If

End Sub

Private Sub Command4_Click()
Clipboard.SetText (Text1.Text)
End Sub

Private Sub Command5_Click()
Text1.Text = Clipboard.GetText
End Sub

Private Sub Command6_Click()
If Text1.Text <> "" Then
Printer.Print Text1.Text
Printer.EndDoc
End If
End Sub

Private Sub Command7_Click()
If Text1.Text <> "" Then
REPLY = MsgBox("QUIT WITHOUT SAVING?", vbYesNo)
If REPLY = vbYes Then End
End If

End Sub

Private Sub Command8_Click()
Form2.Show
End Sub
************************************************** ********

also, is there a way to get the scrollbar to stay invisable until the page is filled in a regular textbox, like it does in a rich text box?

GRIM@GRIMMUSIC.COM
WWW.GRIMMUSIC.COM
__________________
---------------------------
A Black sheep moves easy in the darkness.
GRIM@GRIMMUSIC.COM
WWW.GRIMMUSIC.COM
 
Old December 13th, 2004, 12:20 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Your program is going to thave to respond to the command line argument that the action you described feeds to it, extract the filename from that argument, and open the file itself.
 
Old February 2nd, 2005, 05:34 PM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default

yes, i'm aware of that, and i've made sure that it IS getting the commend line argument, but i still can't figure out how to use it, i've tried the who "line input" and "input file" and "commonfiledialog.filename" and i still haven't gotten it. any examples?

GRIM@GRIMMUSIC.COM
WWW.GRIMMUSIC.COM
 
Old February 2nd, 2005, 05:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

in the form load event add something like

if len(command) > 0 then LoadFile(command)

where LoadFile is the part of the Command2_Click event that open the file, reads it and load into the text box

Marco
 
Old February 6th, 2005, 08:50 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default

you have a point, i'm trying that now.

GRIM@GRIMMUSIC.COM
WWW.GRIMMUSIC.COM
 
Old February 6th, 2005, 09:07 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default

where you say "part of" the command2_click event, can you actually call to part of a procedure likt that? i though if you wanted part of a procedure, you'd have to call to the whole thing? because i'm not getting this still. thanks

GRIM@GRIMMUSIC.COM
WWW.GRIMMUSIC.COM
 
Old February 7th, 2005, 03:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have to split command2_click into two methods:

Private Sub Command2_Click()
CommonDialog1.Filter = "Text Files (*.txt)|*.txt|HTML|*.HTML|All Files|*.*"
CommonDialog1.InitDir = "X:\"
CommonDialog1.ShowOpen
If len(CommonDialog1.FileName)>0 Then
LoadFile commondialog1.filename
endif
end sub

private sub LoadFile(strPath as string)
Text1.Text = ""
Dim strText As String

n = Chr(13) + Chr(10) ' this is a charater return
Open strPath For Input As 1
Do Until EOF(1)
Line Input #1, strText
Text1.Text = Text1.Text & strText & n
Loop
Close #1
End If

End Sub




Similar Threads
Thread Thread Starter Forum Replies Last Post
how can we change the icon of exe file in c++? shiva777 C++ Programming 1 May 13th, 2008 07:00 AM
how to change icon of exe file aashish23 C# 1 September 25th, 2007 08:21 AM
How to add icon file for a web application?? noblez ASP.NET 1.0 and 1.1 Professional 3 April 24th, 2007 02:21 AM
Open .dat and saveas .txt tready Access VBA 6 March 10th, 2006 09:51 PM
Change File Icon red4vbs VBScript 1 January 23rd, 2005 12:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.