By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

is my code accrurate....

P: n/a
i had usercontrol name doColor, then i added function procedure called
doColor. then i added module and called from method doColor into
module. the problem is i had to traced error:...
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
this coming from module method....
in module:
Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String,
Optional ByVal Colour As String = "")

rtb.SelectionStart = rtb.Text.Length
'rtb.doColor(rtb, sText) <==== if i called docolor i got
error problem . but if i rem this....
rtb.SelectedText = sText <=== if i remmed above i got no problem
rtb.SelectionStart = rtb.Text.Length
rtb.ScrollToCaret()
sText = String.Empty

End Sub
i am trying to get irc chat working similar to mirc. but function of
doColor will worked on richextbox that embedded forecolour and
background colour. i had four mdichilds..if that is problem. this
code above will worked on small project i had no problem. i don't know
if my code above is accurate or not.
can ne 1 help me .
regards,

happy new yrs to every 1 >:o

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I suspect you are trying to do something in "docolor" method with sText like
sText.Indexof() when sText is nothing.

"Supra" wrote:
i had usercontrol name doColor, then i added function procedure called
doColor. then i added module and called from method doColor into
module. the problem is i had to traced error:...
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
this coming from module method....
in module:
Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String,
Optional ByVal Colour As String = "")

rtb.SelectionStart = rtb.Text.Length
'rtb.doColor(rtb, sText) <==== if i called docolor i got
error problem . but if i rem this....
rtb.SelectedText = sText <=== if i remmed above i got no problem
rtb.SelectionStart = rtb.Text.Length
rtb.ScrollToCaret()
sText = String.Empty

End Sub
i am trying to get irc chat working similar to mirc. but function of
doColor will worked on richextbox that embedded forecolour and
background colour. i had four mdichilds..if that is problem. this
code above will worked on small project i had no problem. i don't know
if my code above is accurate or not.
can ne 1 help me .
regards,

happy new yrs to every 1 >:o

Nov 21 '05 #2

P: n/a
no!. the sText is to get data from server and displayed in richtextbox
in order to called DisplayMessage in class... this is what i ahve in
class.vb....
Private Sub _Connection_onSeverMessage(ByVal szText As String) Handles
_Connection.onSeverMessage
DisplayMessage(nStatus.rtbStatus, szText.ToString)
End Sub
the only problem is coming from module's method.. i don't if i say sText
is nothing.......i will try it.
regards

Dennis wrote:
I suspect you are trying to do something in "docolor" method with sText like
sText.Indexof() when sText is nothing.

"Supra" wrote:
i had usercontrol name doColor, then i added function procedure called
doColor. then i added module and called from method doColor into
module. the problem is i had to traced error:...
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
this coming from module method....
in module:
Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String,
Optional ByVal Colour As String = "")

rtb.SelectionStart = rtb.Text.Length
'rtb.doColor(rtb, sText) <==== if i called docolor i got
error problem . but if i rem this....
rtb.SelectedText = sText <=== if i remmed above i got no problem
rtb.SelectionStart = rtb.Text.Length
rtb.ScrollToCaret()
sText = String.Empty

End Sub
i am trying to get irc chat working similar to mirc. but function of
doColor will worked on richextbox that embedded forecolour and
background colour. i had four mdichilds..if that is problem. this
code above will worked on small project i had no problem. i don't know
if my code above is accurate or not.
can ne 1 help me .
regards,

happy new yrs to every 1 >:o


Nov 21 '05 #3

P: n/a
this is usercontrol control, then i added method too.
Function doColor(ByVal rtb As RichTextBox, ByVal a As String)
Dim b As String, n, fgcolor, bgcolor As Integer
Dim colour() As Color = {Color.White, Color.Black,
Color.DarkBlue, Color.DarkGreen, Color.Red, Color.Brown, _
Color.Purple, Color.Orange,
Color.Yellow, Color.LightGreen, Color.DarkMagenta, Color.SkyBlue, _
Color.Blue, Color.Magenta,
Color.Gray, Color.LightSlateGray}

fgcolor = 1
bgcolor = 0

For n = 1 To a.Length
b = Mid(a, n, 1)
If b = Chr(3) Then
'Parse Colours
If IsNumeric(Mid(a, n + 1, 1)) Then
If IsNumeric(Mid(a, n + 2, 1)) Then
If Mid(a, n + 3, 1) = "," Then
If IsNumeric(Mid(a, n + 4, 1)) Then
If IsNumeric(Mid(a, n + 5, 1)) Then
'@##,##
fgcolor = CInt(Mid(a, n + 1, 2))
bgcolor = CInt(Mid(a, n + 4, 2))
n += 5

Else
'@##,#
fgcolor = CInt(Mid(a, n + 1, 2))
bgcolor = CInt(Mid(a, n + 4, 1))
n += 4

End If
Else
'@##,
fgcolor = CInt(Mid(a, n + 1, 2))
n += 3

End If
Else
'@##
fgcolor = CInt(Mid(a, n + 1, 2))
n += 2
End If

ElseIf Mid(a, n + 2, 1) = "," Then
If IsNumeric(Mid(a, n + 3, 1)) Then
If IsNumeric(Mid(a, n + 4, 1)) Then
'@#,##
fgcolor = CInt(Mid(a, n + 1, 1))
bgcolor = CInt(Mid(a, n + 3, 2))
n += 4
Else
'@#,#
fgcolor = CInt(Mid(a, n + 1, 1))
bgcolor = CInt(Mid(a, n + 3, 1))
n += 3

End If
Else
'@#,
fgcolor = CInt(Mid(a, n + 1, 1))
n += 2
End If
Else
'@#
fgcolor = CInt(Mid(a, n + 1, 1))
n = n + 1
End If

If fgcolor > 15 Then
fgcolor = 1
End If

If bgcolor > 15 Then
bgcolor = 0
End If

rtb.SelectionColor = colour(fgcolor)
SelectionBackColor = colour(bgcolor)
Else
rtb.SelectionColor = colour(1)
SelectionBackColor = colour(0)
End If

ElseIf b = Chr(2) Then
Dim IsBold As Boolean = ((rtb.SelectionFont.Style
And FontStyle.Bold) = FontStyle.Bold)
rtb.SelectionFont = _
New Font(rtb.SelectionFont,
DirectCast(IIf(IsBold, rtb.SelectionFont.Style And Not FontStyle.Bold,
rtb.SelectionFont.Style Or FontStyle.Bold), FontStyle))

ElseIf b = Chr(31) Then
Dim IsUnderline As Boolean =
((rtb.SelectionFont.Style And FontStyle.Underline) = FontStyle.Underline)
rtb.SelectionFont = _
New Font( _
rtb.SelectionFont, _
DirectCast(IIf(IsUnderline,
rtb.SelectionFont.Style And Not FontStyle.Underline,
rtb.SelectionFont.Style Or FontStyle.Underline), FontStyle))
ElseIf b = Chr(22) Then
Dim IsItalic As Boolean = ((rtb.SelectionFont.Style
And FontStyle.Italic) = FontStyle.Italic)
rtb.SelectionFont = _
New Font( _
rtb.SelectionFont, _
DirectCast(IIf(IsItalic,
rtb.SelectionFont.Style And Not FontStyle.Italic,
rtb.SelectionFont.Style Or FontStyle.Italic), FontStyle))
ElseIf b = "" Then
' b = Mid(a, n, 1)
Else
rtb.SelectedText = b.ToString
End If
b = String.Empty
Next n
End Function
regards,
the above code will worked on small project. this is irc mirc chat colour.

Dennis wrote:
I suspect you are trying to do something in "docolor" method with sText like
sText.Indexof() when sText is nothing.

"Supra" wrote:
i had usercontrol name doColor, then i added function procedure called
doColor. then i added module and called from method doColor into
module. the problem is i had to traced error:...
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
this coming from module method....
in module:
Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String,
Optional ByVal Colour As String = "")

rtb.SelectionStart = rtb.Text.Length
'rtb.doColor(rtb, sText) <==== if i called docolor i got
error problem . but if i rem this....
rtb.SelectedText = sText <=== if i remmed above i got no problem
rtb.SelectionStart = rtb.Text.Length
rtb.ScrollToCaret()
sText = String.Empty

End Sub
i am trying to get irc chat working similar to mirc. but function of
doColor will worked on richextbox that embedded forecolour and
background colour. i had four mdichilds..if that is problem. this
code above will worked on small project i had no problem. i don't know
if my code above is accurate or not.
can ne 1 help me .
regards,

happy new yrs to every 1 >:o


Nov 21 '05 #4

P: n/a
this could be ..
Select Case C(1).Trim
Case "001" To "014", "251" To "272", "372" To "377",
"401", "422", "462", "468", "503"
Dim intA As String = CLi.IndexOf(Nick, 0)
RaiseEvent onSeverMessage(CLi.Substring(intA +
Nick.Length))

is that what u think of "indexof" ?
regards

Supra wrote:
this is usercontrol control, then i added method too.
Function doColor(ByVal rtb As RichTextBox, ByVal a As String)
Dim b As String, n, fgcolor, bgcolor As Integer
Dim colour() As Color = {Color.White, Color.Black,
Color.DarkBlue, Color.DarkGreen, Color.Red, Color.Brown, _
Color.Purple, Color.Orange,
Color.Yellow, Color.LightGreen, Color.DarkMagenta, Color.SkyBlue, _
Color.Blue, Color.Magenta,
Color.Gray, Color.LightSlateGray}

fgcolor = 1
bgcolor = 0

For n = 1 To a.Length
b = Mid(a, n, 1)
If b = Chr(3) Then
'Parse Colours
If IsNumeric(Mid(a, n + 1, 1)) Then
If IsNumeric(Mid(a, n + 2, 1)) Then
If Mid(a, n + 3, 1) = "," Then
If IsNumeric(Mid(a, n + 4, 1)) Then
If IsNumeric(Mid(a, n + 5, 1)) Then
'@##,##
fgcolor = CInt(Mid(a, n + 1, 2))
bgcolor = CInt(Mid(a, n + 4, 2))
n += 5

Else
'@##,#
fgcolor = CInt(Mid(a, n + 1, 2))
bgcolor = CInt(Mid(a, n + 4, 1))
n += 4

End If
Else
'@##,
fgcolor = CInt(Mid(a, n + 1, 2))
n += 3

End If
Else
'@##
fgcolor = CInt(Mid(a, n + 1, 2))
n += 2
End If

ElseIf Mid(a, n + 2, 1) = "," Then
If IsNumeric(Mid(a, n + 3, 1)) Then
If IsNumeric(Mid(a, n + 4, 1)) Then
'@#,##
fgcolor = CInt(Mid(a, n + 1, 1))
bgcolor = CInt(Mid(a, n + 3, 2))
n += 4
Else
'@#,#
fgcolor = CInt(Mid(a, n + 1, 1))
bgcolor = CInt(Mid(a, n + 3, 1))
n += 3

End If
Else
'@#,
fgcolor = CInt(Mid(a, n + 1, 1))
n += 2
End If
Else
'@#
fgcolor = CInt(Mid(a, n + 1, 1))
n = n + 1
End If

If fgcolor > 15 Then
fgcolor = 1
End If

If bgcolor > 15 Then
bgcolor = 0
End If

rtb.SelectionColor = colour(fgcolor)
SelectionBackColor = colour(bgcolor)
Else
rtb.SelectionColor = colour(1)
SelectionBackColor = colour(0)
End If

ElseIf b = Chr(2) Then
Dim IsBold As Boolean = ((rtb.SelectionFont.Style
And FontStyle.Bold) = FontStyle.Bold)
rtb.SelectionFont = _
New Font(rtb.SelectionFont,
DirectCast(IIf(IsBold, rtb.SelectionFont.Style And Not FontStyle.Bold,
rtb.SelectionFont.Style Or FontStyle.Bold), FontStyle))

ElseIf b = Chr(31) Then
Dim IsUnderline As Boolean =
((rtb.SelectionFont.Style And FontStyle.Underline) = FontStyle.Underline)
rtb.SelectionFont = _
New Font( _
rtb.SelectionFont, _
DirectCast(IIf(IsUnderline,
rtb.SelectionFont.Style And Not FontStyle.Underline,
rtb.SelectionFont.Style Or FontStyle.Underline), FontStyle))
ElseIf b = Chr(22) Then
Dim IsItalic As Boolean = ((rtb.SelectionFont.Style
And FontStyle.Italic) = FontStyle.Italic)
rtb.SelectionFont = _
New Font( _
rtb.SelectionFont, _
DirectCast(IIf(IsItalic,
rtb.SelectionFont.Style And Not FontStyle.Italic,
rtb.SelectionFont.Style Or FontStyle.Italic), FontStyle))
ElseIf b = "" Then
' b = Mid(a, n, 1)
Else
rtb.SelectedText = b.ToString
End If
b = String.Empty
Next n
End Function
regards,
the above code will worked on small project. this is irc mirc chat
colour.

Dennis wrote:
I suspect you are trying to do something in "docolor" method with
sText like sText.Indexof() when sText is nothing.

"Supra" wrote:
i had usercontrol name doColor, then i added function procedure
called doColor. then i added module and called from method doColor
into module. the problem is i had to traced error:...
An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of
an object.
this coming from module method....
in module:
Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String,
Optional ByVal Colour As String = "")
rtb.SelectionStart = rtb.Text.Length
'rtb.doColor(rtb, sText) <==== if i called docolor i got
error problem . but if i rem this....
rtb.SelectedText = sText <=== if i remmed above i got no
problem
rtb.SelectionStart = rtb.Text.Length
rtb.ScrollToCaret()
sText = String.Empty
End Sub
i am trying to get irc chat working similar to mirc. but function
of doColor will worked on richextbox that embedded forecolour and
background colour. i had four mdichilds..if that is problem. this
code above will worked on small project i had no problem. i don't
know if my code above is accurate or not.
can ne 1 help me .
regards,

happy new yrs to every 1 >:o


Nov 21 '05 #5

P: n/a
the indeof is parsed nick ...that all

Chicago.IL.US.StarLink.Org 001 djanjo2 :Welcome to the Internet Relay
Network djanjo2
Chicago.IL.US.StarLink.Org 002 djanjo2 :Your host is
Chicago.IL.US.StarLink.Org, running version u2.9.32StarLink2.1
Chicago.IL.US.StarLink.Org 372 djanjo2 :-
Chicago.IL.US.StarLink.Org 003 djanjo2 :This server was created Thu Aug
5 2004 at 07:42:22 CDT

An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.

regards,

Supra wrote:
this is usercontrol control, then i added method too.
Function doColor(ByVal rtb As RichTextBox, ByVal a As String)
Dim b As String, n, fgcolor, bgcolor As Integer
Dim colour() As Color = {Color.White, Color.Black,
Color.DarkBlue, Color.DarkGreen, Color.Red, Color.Brown, _
Color.Purple, Color.Orange,
Color.Yellow, Color.LightGreen, Color.DarkMagenta, Color.SkyBlue, _
Color.Blue, Color.Magenta,
Color.Gray, Color.LightSlateGray}

fgcolor = 1
bgcolor = 0

For n = 1 To a.Length
b = Mid(a, n, 1)
If b = Chr(3) Then
'Parse Colours
If IsNumeric(Mid(a, n + 1, 1)) Then
If IsNumeric(Mid(a, n + 2, 1)) Then
If Mid(a, n + 3, 1) = "," Then
If IsNumeric(Mid(a, n + 4, 1)) Then
If IsNumeric(Mid(a, n + 5, 1)) Then
'@##,##
fgcolor = CInt(Mid(a, n + 1, 2))
bgcolor = CInt(Mid(a, n + 4, 2))
n += 5

Else
'@##,#
fgcolor = CInt(Mid(a, n + 1, 2))
bgcolor = CInt(Mid(a, n + 4, 1))
n += 4

End If
Else
'@##,
fgcolor = CInt(Mid(a, n + 1, 2))
n += 3

End If
Else
'@##
fgcolor = CInt(Mid(a, n + 1, 2))
n += 2
End If

ElseIf Mid(a, n + 2, 1) = "," Then
If IsNumeric(Mid(a, n + 3, 1)) Then
If IsNumeric(Mid(a, n + 4, 1)) Then
'@#,##
fgcolor = CInt(Mid(a, n + 1, 1))
bgcolor = CInt(Mid(a, n + 3, 2))
n += 4
Else
'@#,#
fgcolor = CInt(Mid(a, n + 1, 1))
bgcolor = CInt(Mid(a, n + 3, 1))
n += 3

End If
Else
'@#,
fgcolor = CInt(Mid(a, n + 1, 1))
n += 2
End If
Else
'@#
fgcolor = CInt(Mid(a, n + 1, 1))
n = n + 1
End If

If fgcolor > 15 Then
fgcolor = 1
End If

If bgcolor > 15 Then
bgcolor = 0
End If

rtb.SelectionColor = colour(fgcolor)
SelectionBackColor = colour(bgcolor)
Else
rtb.SelectionColor = colour(1)
SelectionBackColor = colour(0)
End If

ElseIf b = Chr(2) Then
Dim IsBold As Boolean = ((rtb.SelectionFont.Style
And FontStyle.Bold) = FontStyle.Bold)
rtb.SelectionFont = _
New Font(rtb.SelectionFont,
DirectCast(IIf(IsBold, rtb.SelectionFont.Style And Not FontStyle.Bold,
rtb.SelectionFont.Style Or FontStyle.Bold), FontStyle))

ElseIf b = Chr(31) Then
Dim IsUnderline As Boolean =
((rtb.SelectionFont.Style And FontStyle.Underline) = FontStyle.Underline)
rtb.SelectionFont = _
New Font( _
rtb.SelectionFont, _
DirectCast(IIf(IsUnderline,
rtb.SelectionFont.Style And Not FontStyle.Underline,
rtb.SelectionFont.Style Or FontStyle.Underline), FontStyle))
ElseIf b = Chr(22) Then
Dim IsItalic As Boolean = ((rtb.SelectionFont.Style
And FontStyle.Italic) = FontStyle.Italic)
rtb.SelectionFont = _
New Font( _
rtb.SelectionFont, _
DirectCast(IIf(IsItalic,
rtb.SelectionFont.Style And Not FontStyle.Italic,
rtb.SelectionFont.Style Or FontStyle.Italic), FontStyle))
ElseIf b = "" Then
' b = Mid(a, n, 1)
Else
rtb.SelectedText = b.ToString
End If
b = String.Empty
Next n
End Function
regards,
the above code will worked on small project. this is irc mirc chat
colour.

Dennis wrote:
I suspect you are trying to do something in "docolor" method with
sText like sText.Indexof() when sText is nothing.

"Supra" wrote:
i had usercontrol name doColor, then i added function procedure
called doColor. then i added module and called from method doColor
into module. the problem is i had to traced error:...
An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of
an object.
this coming from module method....
in module:
Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String,
Optional ByVal Colour As String = "")
rtb.SelectionStart = rtb.Text.Length
'rtb.doColor(rtb, sText) <==== if i called docolor i got
error problem . but if i rem this....
rtb.SelectedText = sText <=== if i remmed above i got no
problem
rtb.SelectionStart = rtb.Text.Length
rtb.ScrollToCaret()
sText = String.Empty
End Sub
i am trying to get irc chat working similar to mirc. but function
of doColor will worked on richextbox that embedded forecolour and
background colour. i had four mdichilds..if that is problem. this
code above will worked on small project i had no problem. i don't
know if my code above is accurate or not.
can ne 1 help me .
regards,

happy new yrs to every 1 >:o


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.