RTF Notepad App (made in VB.net) I have some problems here which I need help fixing
source, and .exe
The problems I know of are that whenever I attempt to change the font/font size of more than one line, it gives a debug error, saying "Object reference not set to instance of an object". Also, I get that for trying to set multiple lines of text to bold, underline, italics, or strikeout, unless they are the same font. And there's an error where the cause is unknown, where I'll get the same error when doing one line, after closing an error message. When I close the error message and click the box, it selects a line, and when I change the font from there, it gives me an error. It works after deselecting the line and reselecting it though. @wio halp pl0x
@UnkleRhaukus
i don't know computer science yet
dagnabbit D:
not even vb.net programming? :(
in that case, @nincompoop but thanks for actually looking though :p
For @Destinymasha
oright. @inkyvoyd because you do the thing also
"The problems I know of are that whenever I attempt to change the font/font size of more than one line, it gives a debug error, saying 'Object reference not set to instance of an object'." For VB.NET it is 99% of the time mostly caused by you haven't initialized your string, yet you try to access it, thus it compiles yet throws a runtime error when trying to change the value. A simple fix is to set it to a specific value, then you will be able to access and modify the string. (Start with creating a .ini file for settings, and have the text file open with the default font size of 10, that should allow you to circumvent you problem, for the bold font issue, try Boolean data type.) tl;dr Create a default font size without one, you program fails to change the font size, because it doesn't have access to that string since it is not initialized yet. Intellisense should warn you about this... If I remember correctly, it should underline where the issue is too.
I set the default font size with Form1_Load `Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load` ` For Each font As FontFamily In System.Drawing.FontFamily.Families` ` ToolStripComboBox1.Items.Add(Font.Name)` ` Next` ` If ToolStripComboBox1.Items.Contains("Arial") Then` ` ToolStripComboBox1.SelectedItem = "Arial"` ` End If` ` For i = 8 To 72` ` ToolStripComboBox2.Items.Add(i)` ` Next` ` ToolStripComboBox2.SelectedIndex = 3` ` End Sub` Changing the SelectedIndex of the ToolStripComboBox2 immediately triggers the following: `Private Sub ToolStripComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ToolStripComboBox2.SelectedIndexChanged` ` RichTextBox1.SelectionFont = New System.Drawing.Font(RichTextBox1.SelectionFont.Name, Convert.Tosingle(ToolStripComboBox2.SelectedItem.ToString), RichTextBox1.SelectionFont.Style)` ` End Sub` The same thing happens with changing the selecteditem of ToolStripComboBox1, but it triggers the event `Private Sub ToolStripComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ToolStripComboBox1.SelectedIndexChanged` ` RichTextBox1.SelectionFont = New System.Drawing.Font(ToolStripComboBox1.SelectedItem.ToString, RichTextBox1.SelectionFont.Size, RichTextBox1.SelectionFont.Style)` ` End Sub`
Can you compile the program and upload the executable file again?
Sure :3 Just a second tho. Gonna add another thingy doogie to it.
Jk. What I was trying to add wasn't a thing. So:
Before confirming the new font, make a call to the the size of the text and then apply the font and size. (Although the font shouldn't break the size, so maybe you are applying the font parameter incorrectly? (VB.NET isn't my thing, sorry.))
Hmm... Changing font size for more than one line seems to work just fine after selecting both lines and then changing the font.
But I'm not sure what you mean by "make a call to the size of the text"
As values update, the display doesn't update. You need to call, or reference these updates to the display? (Timer that checks?)
Oh right. I'm working on doing something for that right now. I have that set to do it now with richtextbox1.click, but I'm not sure what other events to put it in. I'd do it with textchanged, but that would try to update too much.
Join our real-time social learning platform and learn together with your friends!