Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 22nd, 2003, 09:41 AM
jacksonbilly jacksonbilly is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 15 jacksonbilly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 28 sec
Reputation Power: 0
Save As Dialog Box

Hello to all. I have a script that parses a specific line out of multiple text files in one folder. The problem is this: The parsed information is put in a file in a specific location. How can I bring up a Save As dialog box so that I can choose were to save this file? The code to this script is pasted below and Thanks to all in advance.



Dim fs, ts1, sf, s1, ts2, ProjectDir, WshShell


Const ForReading = 1, ForWriting = 2, ForAppending = 8

FirstPrompt = "Enter Project Directory:"
ErrorMessage = "Operation failed or was canceled!" & vbCrLf & vbCrLf &_
"Please repeat the operation."
FinalMsg = "Map Totals operation complete!"

ProjectDir = InputBox(FirstPrompt,"Map Totals")

Set WshShell = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")

If ProjectDir = "" Then
Dummy = WshShell.Popup (ErrorMessage,0,"Map Totals",16)
Wscript.Quit
Else


WshShell.Run "Cmd.exe /C Copy C:\Cablview\" & ProjectDir & "\Dgn\*.txt C:\Cablview\" & ProjectDir & "\Temp\Totals.txt", 2,True

Set ts1 = fs.OpenTextFile("C:\Cablview\" + ProjectDir + "\Temp\Totals.txt", ForReading)

Set ts2 = fs.OpenTextFile("C:\Cablview\" + ProjectDir + "\Temp\Miles.txt", ForWriting, True)

ReadTotals

Sub ReadTotals()
Do While Not ts1.AtEndOfStream
s1 = ts1.ReadLine()
If InStr(s1, "FTG") > 0 Then
ts2.WriteLine s1

End If
Loop


ts2.Close
ts1.Close
Set ts2 = Nothing
Set ts1 = Nothing
Set fs = Nothing


End Sub

End If

Reply With Quote
  #2  
Old September 23rd, 2003, 03:35 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
To see http://forums.devshed.com/showthrea...save+dialog+box
the Code from PHP-Newb:
<HTML>
<BODY>

<IFRAME id="newFrame" style="display:none"></IFRAME>

<SCRIPT>
function SaveFile(){

var newinfo = "<html>";
newinfo += "<body>This is text from the secondary page.</body>";
newinfo += "</html>";

newFrame.document.open("text/html","replace")
newFrame.document.write(newinfo)
newFrame.document.close()
newFrame.focus()
newFrame.document.execCommand('SaveAs',false,'testfile.txt');
}
</SCRIPT>

This is text from the main page.<BR>

<A HREF=# onClick="SaveFile()">Click to save secondary page.</A>

</BODY>
</HTML>

Reply With Quote
  #3  
Old September 23rd, 2003, 11:40 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
cleverpig, what does html/javascript code have to do with Visual Basic?

Reply With Quote
  #4  
Old September 23rd, 2003, 12:55 PM
jacksonbilly jacksonbilly is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 15 jacksonbilly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 28 sec
Reputation Power: 0
i need a way to prompt for a saveas dialog box (or a common dialog box) using VBcode.

thanks.

Reply With Quote
  #5  
Old September 23rd, 2003, 03:14 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
You should be able to use a inputbox at the appropriate spot.

MyPath = Msgbox("Enter The Path: ")

In VB6 there is also the common dialog control that gives you the standard windows Open / Save As functionality.

Reply With Quote
  #6  
Old September 23rd, 2003, 04:22 PM
jacksonbilly jacksonbilly is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 15 jacksonbilly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 28 sec
Reputation Power: 0
MyPath = Msgbox("Enter The Path: ")

Inserting the above code gives me a small message box with an OK button, but know browse button, or know text box for the path.

Also, I've been researching extensivly, but I can't seem to figure out WERE in my code to put the common dialog control, nor the syntax of it. Ya'll I'm struggling here.

Thanks in advance.

Reply With Quote
  #7  
Old September 23rd, 2003, 04:49 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
What version of VB are you using?

Reply With Quote
  #8  
Old September 24th, 2003, 07:56 AM
jacksonbilly jacksonbilly is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 15 jacksonbilly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 28 sec
Reputation Power: 0
I'm not, I'm using Notepad. And the file's extension is .vbs. I believe it is called Windows Scripting - not sure.

Reply With Quote
  #9  
Old September 24th, 2003, 10:43 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I find a way by vb.net...Hope it's useful..Good luck!
'Put this is a code behind module or asp.net page
Sub DisplayDownloadDialog(ByVal PathVirtual As String)

Dim strPhysicalPath As String
Dim objFileInfo As System.IO.FileInfo
Try
strPhysicalPath = Server.MapPath(PathVirtual)
'exit if file does not exist
If Not System.IO.File.Exists(strPhysicalPath) _
Then Exit Sub
objFileInfo = New System.IO.FileInfo(strPhysicalPath)
Response.Clear()
'Add Headers to enable dialog display
Response.AddHeader("Content-Disposition", "attachment; filename=" & _
objFileInfo.Name)
Response.AddHeader("Content-Length", objFileInfo.Length.ToString())

Response.ContentType = "application/octet-stream"
Response.WriteFile(objFileInfo.FullName)


Catch
'on exception take no action
'you can implement differently
Finally

Response.End()

End Try
End Sub
'DEMO
'IN YOUR CODE BEHIND PAGE:
'DECLARATION
Protected WithEvents btnDownload As _
System.Web.UI.WebControls.Button

'IN CODE
'ASSUMES MYWORDFILE.DOC EXISTS IN SAME FOLDER
'AS THE ASPX FILE
Private Sub btnDownload_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnDownload.Click
DisplayDownloadDialog("MyWordFile.doc")
End Sub
'ON APSX PAGE
<asp:Button id="btnDownload" runat="server" Text="Download a Word File"></asp:Button>

Reply With Quote
  #10  
Old September 24th, 2003, 11:00 AM
jacksonbilly jacksonbilly is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 15 jacksonbilly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 28 sec
Reputation Power: 0
Cleverpig, not sure what you mean by creating an ASP page or module! I mean, I allready have the bulk of the code wrote. I just need a way to choose were to save the page. My code is at the top of this page. Thanks.

Reply With Quote
  #11  
Old September 24th, 2003, 01:13 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
Yep, if you are using a .vbs file on your computer it's Visual Basic Scripting Edition. I don't know how to get to any pre-built file dialog from vbs, I don't do that much scripting outside of ASP.

I meant to use InputBox instead of MsgBox above. InputBox gives you an input field and a return string value.

The MS scripting documentation starts here

http://msdn.microsoft.com/nhp/Defau...tentid=28001169

Maybe poking around in the docs for Windows Script Host (what you're apparently using) and the VBScript docs will turn up something that will help you out.

Reply With Quote
  #12  
Old September 25th, 2003, 01:08 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
hi!jacksonbilly! My code can be used as vbs...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Save As Dialog Box


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |