RICHTEXT BOX
CODE:
Public Class Form1
Private Sub btnBoldAndItalic_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = [Link]("will")
Dim ifont As New Font([Link], [Link])
[Link] = ifont
[Link] = [Link]("way")
Dim bfont As New Font([Link], [Link])
[Link] = bfont
End Sub
Private Sub btnFontColor_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = [Link]
[Link] = [Link]("will")
[Link] = [Link]
[Link] = [Link]("way")
[Link] = [Link]
End Sub
End Class
FORM DESIGN:
1|Page
OUTPUT:
2|Page
DESCRIPTION:
RichTextBoxes are similar to textboxes but they provide some advanced features over the standard
toolbox. RichTextBox allows formatting the text, say adding colors, displaying particular font types and
so on. The RichTextBox, like the TextBox is based on the TextBoxBase class which is based on
the Control class.
To set colors in a rich text box, you can make a selection using the property SelectionStart and
set the rich text box's SelectionColor property. One way to set colors in VB .NET is with the Colors
enumeration, using colors such as [Link], [Link], and so on. The particular word can be
selected using the find () method.
Enter some text in the RichTextBox and the click event of btnBoldAndItalic. The
following code will search for text we mentioned in code and sets it to be display as Bold or Italic based
on what text is searched for. Similarly when the btnFontColor event is clicked, code will search
for text we mentioned in code and sets it to be display in Font floor based on what text is searched for.
3|Page
PERFORMANCE COUNTER
Private counter As PerformanceCounter
Private Sub btnDecrementCounter_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Try
[Link] = False
If [Link] > 0 Then
[Link]()
[Link] = ""
Else
[Link] = "Counter is already zero."
End If
Catch exc As Exception
[Link] = "Could not decrement counter."
End Try
End Sub
Private Sub btnIncrementCounter_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Try
[Link] = False
[Link]()
[Link] = ""
Catch
[Link] = "Could not increment counter."
End Try
End Sub
Private Sub btnRefreshCategories_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
[Link]()
[Link] = Nothing
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = False
[Link] = False
[Link] = ""
[Link] = ""
Me.Form1_Load(Me, New [Link]())
End Sub
Private Sub cboCategories_SelectedIndexChanged(ByVal sender As [Link], ByVal e
As [Link]) Handles [Link]
Dim category As PerformanceCounterCategory
Dim counters As New ArrayList()
Dim thisCounter As PerformanceCounter
Dim counterNames() As String
If [Link] <> -1 Then
Try
category = New PerformanceCounterCategory( _
[Link]())
4|Page
counterNames = [Link]()
If [Link] = 0 Then
[Link]([Link]())
Else
Dim i As Integer
For i = 0 To [Link] - 1
[Link]( _
[Link](counterNames(i)))
Next
End If
[Link]()
[Link] = ""
For Each thisCounter In counters
[Link](New CounterDisplayItem(thisCounter))
Next
Catch exc As Exception
MsgBox("Unable to list the Counters in this Category." + _
"Please select another Category.")
End Try
End If
End Sub
Private Sub cboCounters_SelectedIndexChanged(ByVal sender As [Link], ByVal e
As [Link]) Handles [Link]
Dim displayItem As CounterDisplayItem
Try
displayItem = CType([Link], CounterDisplayItem)
counter = [Link]
[Link] = [Link]()
[Link] = [Link]()
[Link] = ""
If [Link] Then
[Link] = "Custom"
[Link] = True
[Link] = True
Else
[Link] = "Built-In"
[Link] = False
[Link] = False
End If
Catch exc As Exception
counter = Nothing
End Try
End Sub
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim category As PerformanceCounterCategory
Dim categories() As PerformanceCounterCategory
categories = [Link]()
Dim categoryNames([Link] - 1) As String
Dim i As Integer = 0 ' Used as a counter
For Each category In categories
5|Page
categoryNames(i) = [Link]
i += 1
Next
[Link](categoryNames)
Dim nameString As String
For Each nameString In categoryNames
[Link](nameString)
Next
[Link] = 500
[Link] = True
End Sub
Private Sub tmrUpdateUI_Tick(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Try
If Not counter Is Nothing Then
[Link] = [Link]().ToString()
End If
Catch exc As Exception
[Link] = ""
End Try
End Sub
End Class
FORM DESIGN
6|Page
OUTPUT SCREEN
Initiate the performance counter with your Manually Created Performance counter
After refreshing it and choosing the Processor Category
7|Page
DESCRIPTION:
Performance Counters are Windows OS objects that capture metrics about the performance of
hardware and applications. For example, performance counters can capture performance metrics for
processors, memory, threads, events, and processes. Metrics can be used to detect problems or to
“tune” applications and hardware for maximum performance.
Performance Counter objects may be accessed programmatically or with the Windows Performance
Monitor Application (PerfMon).
Listing categories Performance counter categories are retrieved using the GetCategories
method and displayed in a ComboBox control.
Listing counters Performance counters are retrieved using the GetCounters method and
displayed in a ComboBox control. Only the counters from the selected category are retrieved.
Retrieving data The NextValue method is used to retrieve the current value of the selected
counter.
Custom counters The application only allows you to increment custom counters. A custom
counter is defined as a counter where you cannot call the NextValue method.
8|Page