.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

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 ASP Free Forums Sponsor:
  #1  
Old October 28th, 2009, 06:04 AM
kkjjkk kkjjkk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 1 kkjjkk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 38 sec
Reputation Power: 0
Autosave function - Problem

Hi there, I'm making a text editor (like notepad) and I'm trying to include an autosave function. I do however have some trouble with it.

When autosave is turned on:
Code:
Private Sub OnToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnToolStripMenuItem1.Click
        If filesaved = False Then
            MsgBox("You must save the file before turning autosave on")
            Dim save As New SaveFileDialog
            If save.ShowDialog = Windows.Forms.DialogResult.OK Then
                My.Computer.FileSystem.WriteAllText(save.FileName,   TextBox1.Text, False)
            End If
        End If
        Timer1.Enabled = True
        OnToolStripMenuItem1.Checked = True
        OffToolStripMenuItem1.Checked = False
    End Sub


When the autosave timer runs out thus saving:
Code:
Here I want to save the file again, but without the dialog box (I want it to be saved automatically in the path it already is saved in)


Now I know my code seems very clumsy and wierd, however this is one of my very first projects.
I hope that you can help me out!
Kind regards

Reply With Quote
  #2  
Old October 28th, 2009, 07:01 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,461 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Day 16 h 50 m 26 sec
Reputation Power: 1806
Hi, and welcome to the forums. What happens when you run this, does it give you the save dialog box each time the timer runs out?

Try storing the filename in a variable, then test to see if this variable contains a value, eg:
Code:
'Define a variable at the top of your page so that it is accessible by all functions

Dim strFileName As String 

Private Sub OnToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnToolStripMenuItem1.Click
        If strFileName = "" Then
            MsgBox("You must save the file before turning autosave on")
            Dim save As New SaveFileDialog
            If save.ShowDialog = Windows.Forms.DialogResult.OK Then
                My.Computer.FileSystem.WriteAllText(save.FileName,   TextBox1.Text, False)
                strFileName = save.FileName
            End If
        Else
            My.Computer.FileSystem.WriteAllText(strFileName, TextBox1.Text, False)
        End If
        Timer1.Enabled = True
        OnToolStripMenuItem1.Checked = True
        OffToolStripMenuItem1.Checked = False
    End Sub

Reply With Quote
  #3  
Old October 28th, 2009, 11:10 AM
vb5prgrmr vb5prgrmr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 2 vb5prgrmr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 12 sec
Reputation Power: 0
and perhaps use the .NET forum next time

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Autosave function - Problem


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





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek