473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

is my code accrurate....

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
5 1175
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
5
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.