program vb net


NAMA : VASKO EDO GULTOM
NIM :071402009

TUGAS MINGGUAN IV
TPL 305 PEMOGRAMAN .NET

12.5 Write a temperature conversion program that converts from Fahrenheit to Celsius. The Fahrenheit
temperature should be entered from the keyboard (via a TextBox). A Label should be used
to display the converted temperature. Use the following formula for the conversion:
Celsius = 5 / 9 x ( Fahrenheit – 32 )
Jawab;

Kodennya adalah;
Public Class frmtemperatureconversion

Private Sub frmtemperatureconversion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub mnucelsius_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnucelsius.Click
Me.rbcelsius.Checked = True
Me.btnanswer.Text = “Celsius”
Me.lblenter.Text = “Enter the temperature in Fahrenheit:”
Me.lblcelsius.Text = “The temperature in Celsius is:”

Dim sngtemperature As Single
Dim sngfinaltemperature As Single

sngtemperature = Val(Me.tbfahrenheit.Text)

If rbcelsius.Checked = True Then
sngfinaltemperature = (sngtemperature – 32) * (5 / 9)
Else
sngfinaltemperature = (sngtemperature * 9 / 5) + 32
End If

Me.lblanswer.Text = sngfinaltemperature

End Sub

Private Sub mnufahrenheit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnufahrenheit.Click
Me.rbfahrenheit.Checked = True
Me.btnanswer.Text = “Fahrenheit”
Me.lblenter.Text = “Enter the temperature in Celsius:”
Me.lblcelsius.Text = “The temperature in Fahrenheit is:”

Dim sngtemperature As Single
Dim sngfinaltemperature As Single

sngtemperature = Val(Me.tbfahrenheit.Text)

If rbfahrenheit.Checked = True Then
sngfinaltemperature = (sngtemperature * 9 / 5) + 32
Else
sngfinaltemperature = (sngtemperature – 32) * (5 / 9)
End If

Me.lblanswer.Text = sngfinaltemperature

End Sub

Private Sub mnuexit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuexit.Click
End
End Sub

Opsi pilihan form ke 2 adalah sebagai berikut;

:
Private Sub btConvert_Click()
Dim enterTemp As Single, newTemp As Single

enterTemp = Val(txTemperature.Text)

If opFahr.Value Then
newTemp = 9 * (enterTemp / 5) + 32
Else
newTemp = 5 * (enterTemp – 32) / 9
End If

lbNewtemp.Caption = Str$(newTemp)
End Sub
‘——
Private Sub Closit_Click()
End
End Sub

13.6 Create a file browser (similar to Windows Explorer) based on the programs in Fig. 13.8,
Fig. 13.22 and Fig. 13.25. The file browser should have a TreeView, which allows the user to
browse directories. There should also be a ListView, which displays the contents (all subdirectories and files) of the directory being browsed. Double-clicking a file in the ListView should open it, and double-clicking a directory in either the ListView or the TreeView should browse it. If a file or directory cannot be accessed, because of its permission settings, notify the user.
Jawab;

Source kodenya adalah;

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Private Sub Dir1_Change()
File1 = Dir1
File2 = Dir2
End Sub

Private Sub Drive1_Change()
Dir1 = Drive1
Dir2 = Drive2
Label1 = Dir1

End Sub

Private Sub Form_Load()
Label1 = Dir1
End Sub

End Sub
End Class

13.7 Create an MDI text editor. Each child window should contain a multiline RichTextBox. The MDI parent should have a Format menu, with submenus to control the size, font and color of the text in the active child window. Each submenu should have at least three options. In addition, the parent should have a File menu with menu items New (create a new child), Close (close the active child) and Exit (exit the application). The parent should have a Window menu to display a list of the open child windows and their layout options.
Jawab;

Source kodenya adalah;
Private Sub Form_Load()

End Sub

Private Sub mnuClose_Click()
Unload(Me)
End Sub

Private Sub mnucopen_Click()
Unload(Me)
End Sub

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s