aijohn
asked on
saving and recalling text in note card script
Two different solutions for the question below in Q_21123047
************************** ********** **********
I'm trying to create a personal reminder feature as part of a program. Need help on
Double click on form which
produces a message box with a textbox for title
giving a small box on the form with the title
double click on title brings up a text area to make notes related to subject
all the small boxes visible on the form with capabality of being dragged and having text edited.
************************** ********** ********** ********** ******
Next question. How do I save to notes1.txt, then rerun with notes1.txt as input,add more
notes, save as notes2.txt and so on and so on.
**************************
I'm trying to create a personal reminder feature as part of a program. Need help on
Double click on form which
produces a message box with a textbox for title
giving a small box on the form with the title
double click on title brings up a text area to make notes related to subject
all the small boxes visible on the form with capabality of being dragged and having text edited.
**************************
Next question. How do I save to notes1.txt, then rerun with notes1.txt as input,add more
notes, save as notes2.txt and so on and so on.
Ofcourse it still needs some bells and whistles but I leave that up to you.
One thing for instance is when you load the xml, all the notes will be on top of each other. so you need to alter the left and top properties of your labels in the loop
One thing for instance is when you load the xml, all the notes will be on top of each other. so you need to alter the left and top properties of your labels in the loop
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Pff, I think I just wrote you a complete application ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Idle_mind,
Correction, I think WE just wrote him a complete application ;-)
Correction, I think WE just wrote him a complete application ;-)
ASKER
Thanks again to both of you for a rapid intro to vb.net. Unfortunately I will probably be spending
most of the day on something else not half as interesting so it will probably be later tonight before
I have a chance to mess up your beautiful code.
You are doing a great job of accelerating the learning curve.
aijohn
most of the day on something else not half as interesting so it will probably be later tonight before
I have a chance to mess up your beautiful code.
You are doing a great job of accelerating the learning curve.
aijohn
It was a fun little app to write.
I'm sure many would be appalled at my use of the Tag property, an inner private class and *gasp* binary serialization.
I've never actually tried XML serialization...need to try that out... =)
I think the code is easy enough to understand though and between your submission and mine, aijohn has gotten a good look at two different approaches to the same problem.
Regards,
{pseudocode} / {Time} ± ¼*ƒ(Me.Thoughts÷3)^² = Idle »(°_°)« Mind
I'm sure many would be appalled at my use of the Tag property, an inner private class and *gasp* binary serialization.
I've never actually tried XML serialization...need to try that out... =)
I think the code is easy enough to understand though and between your submission and mine, aijohn has gotten a good look at two different approaches to the same problem.
Regards,
{pseudocode} / {Time} ± ¼*ƒ(Me.Thoughts÷3)^² = Idle »(°_°)« Mind
There a few alterations to make this work. Here is the code.
the module is the same as is the mynote class
<Serializable()> Public Class notescontainer
'Public notes As ArrayList
Public notes As New Hashtable
Public Sub AddNote(ByVal TT As String, ByVal ttt As String)
Dim s As New mynote(TT, ttt)
notes.Add(s.Title, s)
End Sub
Public Function ReturnNoteText(ByVal tt As String) As String
Return CType(notes.Item(tt), mynote).Notetext
End Function
Public Sub SaveXml(ByVal Path As String)
Dim fStream As System.IO.FileStream
Dim myFormat As New System.Runtime.Serializati
Try
fStream = New System.IO.FileStream(Path,
myFormat.Serialize(fStream
fStream.Close()
Catch ex As Exception
MsgBox("Error saving: " & ex.Message)
Finally
If Not (fStream Is Nothing) Then fStream.Close()
End Try
End Sub
Public Shared Function LoadXML(ByVal Path As String) As Hashtable
Dim fStream As System.IO.FileStream
Dim myFormat As New System.Runtime.Serializati
Dim tmp As Hashtable
Try
fStream = New System.IO.FileStream(Path,
IO.FileAccess.Read)
tmp = CType(myFormat.Deserialize
Catch ex As Exception
MsgBox("Error opening: " & ex.Message)
tmp = Nothing
Finally
If Not (fStream Is Nothing) Then fStream.Close()
End Try
Return tmp
End Function
End Class
Add a load button to your form that containes the notes and but this code in it
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim tmp As Hashtable
tmp = notescontainer.LoadXML("c:
For Each x As String In tmp.Keys
Dim lb As New Label
lb.SendToBack()
lb.BorderStyle = BorderStyle.Fixed3D
lb.Text = x
lb.Top = 10
lb.Left = 10
lb.Height = 50
lb.Width = 50
AddHandler lb.DoubleClick, AddressOf labelDclick
AddHandler lb.MouseDown, AddressOf lbmousedown
AddHandler lb.MouseUp, AddressOf lbmouseup
AddHandler lb.MouseMove, AddressOf lbmousemove
Me.Controls.Add(lb)
c.notes = tmp
Next
End Sub
Add a save button to your form that containes the notes and but this code in it
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
c.SaveXml("c:\ttt.xml")
End Sub
Then you can save and load notes
If you need any additional help with this let me know