0% found this document useful (0 votes)
25 views3 pages

Laporan Tugas 1 Pemograman Visual: Imports Public Class Private Sub Byval As Byval As Handles

This document is a report for Programming Visual Lab Assignment 1. It contains the student's name, student ID, class, and course information. The code opens a text file, reads each line and adds it to a listbox. It then separates the even and odd numbers into two other listboxes and calculates the sum of each.

Uploaded by

dandi_e
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Laporan Tugas 1 Pemograman Visual: Imports Public Class Private Sub Byval As Byval As Handles

This document is a report for Programming Visual Lab Assignment 1. It contains the student's name, student ID, class, and course information. The code opens a text file, reads each line and adds it to a listbox. It then separates the even and odd numbers into two other listboxes and calculates the sum of each.

Uploaded by

dandi_e
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

LAPORAN TUGAS 1

PEMOGRAMAN VISUAL

Nama : Dandy Erlangga


NIM : 08.01.037
Kelas : TI3E
Mata Kuliah : Lab. Pemograman Visual

Source

Imports System.IO
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

MsgBox("Nama : Dandy Erlangga")


MsgBox("N I M : 08.01.037")
MsgBox("Kelas : TI3E")
MsgBox("MK : Lab. Pemograman Visual")

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
'menampilkan dialog untuk membuka file
If OpenFileDialog1.ShowDialog() = _
Windows.Forms.DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
End If

'membaca file text


Dim namafile As String
namafile = TextBox1.Text

'periksa dulu apakah file ada di komputer


If My.Computer.FileSystem.FileExists(namafile) Then
MsgBox("OK.File " & namafile & " ada.", _
MsgBoxStyle.Information)
Else
MsgBox("Error.File " & namafile & " tidak ada!", _
MsgBoxStyle.Exclamation)
Exit Sub
End If

Dim sr As StreamReader = New StreamReader(namafile)


'ingat harus pakai imports system.IO
Dim str As String
str = sr.ReadLine()
' ReadLine membaca satu baris (tdk termasuk karakter new line)
Do While str <> Nothing ' memeriksa apakah ada isinya
ListBox1.Items.Add(str)
str = sr.ReadLine()
Loop
' optional: property penting di ListBox yg bisa diset:
' HorizontalScrollbar)

'membuat variabel untuk penjumlahan di listbox1


Dim i As Integer
Dim x As Integer
Dim s As String
Dim y As Integer

'membuat variabel untuk penjumlahan di listbox2


Dim i1 As Integer
Dim x1 As Integer
Dim s1 As String
Dim y1 As Integer

'membuat variabel untuk penjumlahan di listbox3


Dim i2 As Integer
Dim x2 As Integer
Dim s2 As String
Dim y2 As Integer

i = ListBox1.Items.Count
y = 0
For x = 0 To (i - 1)
s = ListBox1.Items.Item(x)
y = y + s
Label5.Text = "Jumlah = " & y

If (s Mod 2 = 0) Then
ListBox3.Items.Add(s)
Else
ListBox2.Items.Add(s)
End If
Next

i1 = ListBox2.Items.Count
y1 = 0
For x1 = 0 To (i1 - 1)
s1 = ListBox2.Items.Item(x1)
y1 = y1 + s1
Label6.Text = "Jumlah = " & y1
Next

i2 = ListBox3.Items.Count
y2 = 0
For x2 = 0 To (i2 - 1)
s2 = ListBox3.Items.Item(x2)
y2 = y2 + s2
Label7.Text = "Jumlah = " & y2
Next
End Sub
End Class

You might also like