Assignment VBDOTNET
Assignment VBDOTNET
CODE:
Public Class Form1
Private Sub btnBoldAndItalic_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBoldAndItalic.Click
rtxtBoldAndItalic.SelectionStart = rtxtBoldAndItalic.Find("will")
Dim ifont As New Font(rtxtBoldAndItalic.Font, FontStyle.Italic)
rtxtBoldAndItalic.SelectionFont = ifont
rtxtBoldAndItalic.SelectionStart = rtxtBoldAndItalic.Find("way")
Dim bfont As New Font(rtxtBoldAndItalic.Font, FontStyle.Bold)
rtxtBoldAndItalic.SelectionFont = bfont
End Sub
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 Colors.Red, Colors.Green, 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
Try
counter.ReadOnly = False
End Sub
Try
counter.ReadOnly = False
counter.Increment()
ToolStripStatusLabel1.Text = ""
Catch
ToolStripStatusLabel1.Text = "Could not increment counter."
End Try
End Sub
If counterNames.Length = 0 Then
counters.AddRange(category.GetCounters())
Else
Dim i As Integer
For i = 0 To counterNames.Length - 1
counters.AddRange( _
category.GetCounters(counterNames(i)))
Next
End If
Me.cboCounters.Items.Clear()
Me.cboCounters.Text = ""
For Each thisCounter In counters
Me.cboCounters.Items.Add(New CounterDisplayItem(thisCounter))
Next
End If
End Sub
If displayItem.IsCustom Then
Me.txtBuiltInOrCustom.Text = "Custom"
Me.btnDecrementCounter.Enabled = True
Me.btnIncrementCounter.Enabled = True
Else
Me.txtBuiltInOrCustom.Text = "Built-In"
Me.btnDecrementCounter.Enabled = False
Me.btnIncrementCounter.Enabled = False
End If
Me.tmrUpdateUI.Interval = 500
Me.tmrUpdateUI.Enabled = True
End Sub
Private Sub tmrUpdateUI_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmrUpdateUI.Tick
Try
If Not counter Is Nothing Then
Me.txtCounterValue.Text = counter.NextValue().ToString()
End If
Catch exc As Exception
Me.txtCounterValue.Text = ""
End Try
End Sub
End Class
FORM DESIGN
6|Page
OUTPUT SCREEN
Initiate the performance counter with your Manually Created Performance counter
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