Introduction to Visual Studio and Visual basic | Bài báo cáo học phần Scada Lab | Trường Đại học Quốc tế, Đại học Quốc gia Thành phố Hồ Chí Minh
Based on the Designing guide and the Coding guide, I have designed an application that has 2 tabs and archives all the requirements. Tab 1 can calculate basic operations and solve quadratic equations. Tab 2 can change the color of the name and the ID based on 3 color values red, green, blue; it also can write (save) or read (open) a text file and send 3 types of messages with manual title and information. Tài liệu giúp bạn tham khảo, ôn tập và đạt kết quả cao. Mời bạn đón xem.
Môn: Scada Lab
Trường: Trường Đại học Quốc tế, Đại học Quốc gia Thành phố Hồ Chí Minh
Thông tin:
Tác giả:
Preview text:
VIETNAM NATIONAL UNIVERSITY – HOCHIMINH CITY
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING SCADA LAB EEAC003IU
INTRODUCTION TO VISUAL STUDIO AND VISUAL BASIC Submitted by
Nguyễ n Đứ c Thị nh – EEACIU21064 Datễ Submịttễd: Aprịl 7th, 2024 Datễ Pễrformễd: Aprịl 1st, 2024 Lab Sễctịon: 1 Coursễ Instructor: N.V.Bịnh
International University
School of Electrical Engineering
GRADING GUIDELINE FOR LAB REPORT
Number Content Score Comment 1 Format (max 9%) - Font typễ Yễs No
- Font sịzễ Yễs No - Lab tịtlễ Yễs No
- Pagễ numbễr Yễs No
- Tablễ of contễnts Yễs No - Hễadễr/Footễr Yễs No
- Lịst of fịgurễs (ịf ễxịsts) Yễs No
- Lịst of tablễs (ịf ễxịsts) Yễs No
- Lab rễport structurễ Yễs No 2
English Grammar and Spelling (max 6%) - Grammar Yễs No - Spễllịng Yễs No 3
Data and Result Analysis (max 85%) Total Score
[Power Electronics Lab] [EEAC003IU] Sịgnaturễ: Datễ: Table of Contents
List of Figures ............................................................................................................ ....................... II
List of Tables ...................................................................................................................................... II
Nomenclature ............................................................................................................... .................... II
1 Theoretical Background ............................................................................................................ 1
2 Experimental Procedure ........................................................................................................... 1
2.1 Task 1: ........................................................................................................................................................ 1
2.2 Task 2 .......................................................................................................................................................... 2
3 Experimental Results .................................................................................................................. 4
3.1 Expễrịmễnt 1 ........................................................................................................................................... 4
3.2 Expễrịmễnt 2 ........................................................................................................................................... 6
4 Discussion of Results .................................................................................................................. 8
International University
School of Electrical Engineering List of Figures
Fịgurễ 1: Task 1.. ........................................................................................................................................... 2 Fịgurễ
2: Task 2.. ........................................................................................................................................... 4
Fịgurễ 3: Result Task 1.. .............................................................................................................................. 5
Fịgurễ 4: Result Task 2.. .............................................................................................................................. 7 List of Tables
Tablễ 1: Common controls. .......................................................... Error! Bookmark not defined. Nomenclature
[Power Electronics Lab] [EEAC003IU]
International University
School of Electrical Engineering II
1 Theoretical Background
Table 1. Common controls.
2 Experimental Procedure 2.1 Task 1:
Design a following user interface:
[Power Electronics Lab] 1 [EEAC003IU]
International University
School of Electrical Engineering
- In “Basic Operation”:
Select number from (1) and (3) and the operator from (2) combobox. When user click
“Calculation” button, the result will be displayed below in a textbox.
- In “Quadratic Equation”:
Input a parameter of the quadratic equation in (6), (7) and (8) textboxes. When user click
“Solve”, calculate the answer and show on 2 textboxes below, and only consider when the
equation have real number answers.
Solve the equation even when a, b or c equal zero. Figure 1. Task 1. 2.2 Task 2
Create a new TabPage next to “Basic Math” tab and name it “Dialog and Message Box”.
- In “Color Changing”:
When user change value of color (red, green, blue) by the (2), (3) or (4) trackbars, the color
of the form title (1) will be changed to that color.
- In “Open and Save File Dialog”:
[Power Electronics Lab] 2 [EEAC003IU]
International University
School of Electrical Engineering
When user click on “Open” button, a dialog will show up and allow user to select a text
file (*.txt) to open. If user chose a file and click “OK”, the file will be displayed on the textbox (7) below.
When user click “Save” button, a dialog will show up and allow user to select where to
save the text file (*.txt). If user click “Save”, the text from the textbox (7) will save to that file.
- In “Message Box”:
User select one type of Message (Notification (8), Warning (9) or Error (10)). User inputs
the title text and message text in (11) and (12) textboxes.
When user clicks “Display” button, a message box will show up with the same type and text as it has been set up. Figure 2. Task 2
[Power Electronics Lab] 3 [EEAC003IU]
International University
School of Electrical Engineering 3 Experimental Results 3.1 Experiment 1
Figure 3 Result Task 1 Code: Imports Systễm.Xml Public Class Form1
Private Sub CalculateButton_Click(sender As Object, e As EventArgs) Handles CalculateButton.Click Dim result As Double
If OperatorListBox.SelectedItem IsNot Nothing Then
Select Case OperatorListBox.SelectedItem.ToString() Case ("Add")
result = FirstNumeric.Value + SecondNumeric.Value Case ("Subtract")
result = FirstNumeric.Value - SecondNumeric.Value Case ("Multiply")
[Power Electronics Lab] 4 [EEAC003IU]
International University
School of Electrical Engineering
result = FirstNumeric.Value * SecondNumeric.Value Case ("Divide")
If SecondNumeric.Value <> 0 Then
result = FirstNumeric.Value / SecondNumeric.Value Else
OperationResultTextBox.Text = "Undefined" Return End If End Select
OperationResultTextBox.Text = result.ToString("0.00") End If End Sub
Private Sub SolveButton_Click(sender As Object, e As EventArgs) Handles SolveButton.Click Dim a, b, c As Double
Double.TryParse(ATextBox.Text, a)
Double.TryParse(BTextBox.Text, b)
Double.TryParse(CTextBox.Text, c) If a <> 0 Then Dim delta As Double
delta = Math.Sqrt(b * b - 4 * a * c) If Double.IsNaN(delta) Then X1TextBox.Text = "NaN" X2TextBox.Text = "NaN" Return Else
X1TextBox.Text = ((-b - delta) / (2 * a)).ToString("0.00")
X2TextBox.Text = ((-b + delta) / (2 * a)).ToString("0.00") End If ElseIf b <> 0 Then
X1TextBox.Text = (-c / b).ToString("0.00") X2TextBox.Text = "" ElseIf c <> 0 Then X1TextBox.Text = "Null" X2TextBox.Text = "" Else
X1TextBox.Text = "Any Number" X2TextBox.Text = "" End If End Sub End Class
[Power Electronics Lab] 5 [EEAC003IU]
International University
School of Electrical Engineering 3.2 Experiment 2
Figure 4 Result Task 2 Code: Imports System.Xml Imports System.IO Private Sub ColorChange()
FormTitleLabel.ForeColor = Color.FromArgb(RedTrackBar.Value,
GreenTrackBar.Value, BlueTrackBar.Value) End Sub
Private Sub RedTrackBar_ValueChanged(sender As Object, e As EventArgs)
Handles RedTrackBar.ValueChanged ColorChange() End Sub
Private Sub GreenTrackBar_ValueChanged(sender As Object, e As EventArgs)
[Power Electronics Lab] 6 [EEAC003IU]
International University
School of Electrical Engineering
Handles GreenTrackBar.ValueChanged ColorChange() End Sub
Private Sub BlueTrackBar_ValueChanged(sender As Object, e As EventArgs)
Handles BlueTrackBar.ValueChanged ColorChange() End Sub
Private Sub OpenFileButton_Click(sender As Object, e As EventArgs) Handles OpenFileButton.Click
Dim OpenFileDialog = New OpenFileDialog()
OpenFileDialog.Filter = "Text Documents|*.txt|All File Types|*.*"
OpenFileDialog.Multiselect = False
If OpenFileDialog.ShowDialog() = DialogResult.OK Then FileContentTextbox.Text =
File.ReadAllText(OpenFileDialog.FileName) End If End Sub
Private Sub SaveFileButton_Click(sender As Object, e As EventArgs) Handles SaveFileButton.Click
Dim SaveFileDialog = New SaveFileDialog()
SaveFileDialog.Filter = "Text Documents|*.txt|All File Types|*.*"
SaveFileDialog.AddExtension = True
If SaveFileDialog.ShowDialog() = DialogResult.OK Then
File.WriteAllText(SaveFileDialog.FileName, FileContentTextbox.Text) End If End Sub
Private Sub DisplayMessageButton_Click(sender As Object, e As EventArgs)
Handles DisplayMessageButton.Click
If NotificationRadioButton.Checked Then
MsgBox(MessageTextBox.Text, MsgBoxStyle.Information, TitleTextBox.Text)
ElseIf WarningRadioButton.Checked Then
MsgBox(MessageTextBox.Text, MsgBoxStyle.Exclamation, TitleTextBox.Text)
ElseIf ErrorRadioButton.Checked Then
MsgBox(MessageTextBox.Text, MsgBoxStyle.Critical, TitleTextBox.Text) End If End Sub End Class
[Power Electronics Lab] 7 [EEAC003IU]
International University
School of Electrical Engineering
4 Discussion of Results
Basễd on thễ Designing guide and the Coding guide, I have designed an application that has 2
tabs and archives all the requirements. Tab 1 can calculate basic operations and solve quadratic
equations. Tab 2 can change the color of the name and the ID based on 3 color values red, green,
blue; it also can write (save) or read (open) a text file and send 3 types of messages with manual title and information
[Power Electronics Lab] 8 [EEAC003IU]