TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Emmery Chrisco
NA
6
9.6k
save/retrieve font settings
Aug 12 2010 3:08 PM
I am trying to save the last used font, font color, and background color. Then when starting myapp up again, read the data and use the last used settings. Make since?
Here is what I have so far:
User pick new font &/or color
[CODE]
If FontDialog1.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
MainText.Font = FontDialog1.Font
MainText.ForeColor = FontDialog1.Color
End If
FontType = FontDialog1.Font.ToString
FontColor = FontDialog1.Color.ToString
[/CODE]
Last used font and color saved to file
[CODE]
FileOpen(1, Application.StartupPath & "\Settings.txt", OpenMode.Output)
WriteLine(1, "Font = " & FontType)
WriteLine(1, "FontColor = " & FontColor)
FileClose(1)
[/CODE]
Program retrieves last used setting when opening
[CODE]
If System.IO.File.Exists(Application.StartupPath & "\Settings.txt") = True Then
FileOpen(1, Application.StartupPath & "\Settings.txt", OpenMode.Input)
Do Until EOF(1)
Input(1, strinput)
If Trim(strinput).StartsWith("Font") Then
split = strinput.Split("=")
FontType= Trim(split(1))
MainText.Font = FontType '***ERROR HERE
End If
Loop
FileClose(1)
End If
[/CODE]
*** Value of type 'string' cannot be converted to 'System.Drawing.Font'.
Besides getting the value to the right type, it looks like some more trimming will be necessary as well (unless the [brackets] are supposed to be there).
I hope someone out there is smarter than me.
Reply
Answers (
2
)
Visual Basic 6.0
How To: Control the exact position of the mouse on your screen (Outside of the form)