Check if Richtextbox saved?

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
12 posts Page 1 of 2
Contributors
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Check if Richtextbox saved?
zachman61
ok before we start,
im using a tabcontrol and generating the richtextbox.
rtb = richtextbox
so how would i check if the tab's rtb has saved?
and have it save every 5 minutes or so?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Check if Richtextbox saved?
GoodGuy17
EDIT: Do you want auto-save too?

Under Public Class Form1,
Code: Select all
Public rtbArray() As Boolean
Public tabCount As Integer
In a save event,
Code: Select all
Dim tabInt As Integer
tabInt = TabControl1.SelectedIndex
rtbArray(tabInt) = True
In the new tab event,
(add this alongside your new tab functions)
Code: Select all
tabCount += 1
ReDim Preserve rtbArray(tabCount)
In a timer with it's interval at 300000,
Code: Select all
For i = 0 To UBound(rtbCount)
If rtbCount(i) = False Then
CType(TabControl1.TabPages.Item(i).Controls(0), RichTextBox).SaveFile(path)
End If
Next i
NOTE FOR TIMER: Change path to the path you want it to save to, and if you want to save it as a specific file type, put a comma after the path. If you get an error on this line:

For i = 0 To UBound(rtbCount)

then add "- 1" after the closing parenthesis.

If I helped, +rep please :)
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Check if Richtextbox saved?
zachman61
ok, the autosave seems to work, ill try the other things now.

EDIT:
i get an error in this sub
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        For i = 0 To UBound(rtbCount)
            If Count(i) = False Then
                CType(TabControl1.TabPages.Item(i).Controls(0), RichTextBox).SaveFile(path)
            End If
        Next i
    End Sub
Error1: rtbCount is not declared.
Error2: Count is not declared.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Check if Richtextbox saved?
GoodGuy17
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        For i = 0 To UBound(rtbCount)
            If rtbCount(i) = False Then
                CType(TabControl1.TabPages.Item(i).Controls(0), RichTextBox).SaveFile(path)
            End If
        Next i
    End Sub
Fixed. Make sure rtbCount() is declared under Public Class Form1.
User avatar
MasterComputer
Just Registered
Just Registered
Posts: 4
Joined: Thu Jul 22, 2010 11:26 am

you can make it save the path when the user saves it and then on exit make it open the file and compare it
Huh, i got banned for reporting a bug. The admin thought i had exploited it when i haven't, there isn't even evidence i had exploited it, but when i tried explaining that i hadn't they didn't understand me. After the ban i also lost 107 credits to make it more "fun".
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Check if Richtextbox saved?
zachman61
GoodGuy17 wrote:
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        For i = 0 To UBound(rtbCount)
            If rtbCount(i) = False Then
                CType(TabControl1.TabPages.Item(i).Controls(0), RichTextBox).SaveFile(path)
            End If
        Next i
    End Sub
Fixed. Make sure rtbCount() is declared under Public Class Form1.
Im not the brightest with declaring.
I declared it as
Code: Select all
Dim rtbCount() As Boolean
is this what i was supposed to declare as?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Check if Richtextbox saved?
GoodGuy17
Hmm...
Redo my steps above and see if you missed something. I cannot see why it would tell you rtbCount is not declared unless you didn't put it under Public Class Form1.
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Check if Richtextbox saved?
zachman61
GoodGuy17 wrote:
Hmm...
Redo my steps above and see if you missed something. I cannot see why it would tell you rtbCount is not declared unless you didn't put it under Public Class Form1.
in your steps above rtbCount is not mentioned.
and i did rtbCount as Boolean
and i got this error when opening the debugging the form
Code i got Error From:
Code: Select all
  For i = 0 To UBound(rtbcount)
Error i got from this code:
Code: Select all
Value cannot be null.
Parameter name: Argument 'Array' is Nothing.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Check if Richtextbox saved?
GoodGuy17
Ooohh ouch lol. I got scrambled up and put rtbCount instead of rtbArray. Replace the timer's code with this:
Code: Select all
For i = 0 To UBound(rtbArray)
If rtbArray(i) = False Then
CType(TabControl1.TabPages.Item(i).Controls(0), RichTextBox).SaveFile(path)
End If
Next i
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Check if Richtextbox saved?
zachman61
ooh lol :D
EDIT:
Does Vb2010 have a autosave function like office 2007-2010?
because i was just working on this project and had a lot of work done and it crashed cryer;
and it hasn't seemed to have saved an autorecovery like word.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
12 posts Page 1 of 2
Return to “Tutorial Requests”