Senin, 25 Januari 2016

MENCETAK KARAKTER

ASSALAMU'ALAIKUM WARAHMATULLAHI WABAROKATUH :)
 
SELAMAT DATANG DI BLOG SAYA, SAYA AKAN MEMPOSTING MENGENAI  PROGRAM VISUAL BASIC 10 YANG SAYA BUAT

PROJECT LATIHAN    13
MENCETAK KARAKTER
BERIKUT ADALAH CODING MENCETAK KARAKTER:
Public Class Frmlat_13
    Dim banyak As Integer
    Dim kar, karn As String

    Sub cetak_hasil()
        Dim u1, u2 As Integer
        banyak = Val(Me.Txtbanyak.Text)
        kar = Me.Txtkarakter.Text
        'step1
        u1 = 1

        While (u1 <= banyak)
            u2 = 1
            While (u2 <= u1)
                karn = karn & kar

                u2 += 1
            End While
            karn = karn & Chr(13)

            u1 += 1
        End While
        'step2
        u1 = banyak - 1
        While (u1 >= 1)
            u2 = 1
            While (u2 <= u1)
                karn = karn & kar

                u2 += 1
            End While
            karn = karn & Chr(13)

            u1 -= 1
        End While

        Me.Lbhasil.Text = karn

    End Sub

    Private Sub Bproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bproses.Click
        If Val(Me.Txtbanyak.Text) >= 1 And Me.Txtkarakter.Text <> "" And Me.Txtkarakter.Text <> " " Then
            'OK
            Call cetak_hasil()


        Else

            'Bermasalah
            MsgBox("jumlah perulangan tidak benar atau karakter kosong ", vbCritical, "masalah")

            Me.Txtbanyak.Focus()

        End If

    End Sub

    Private Sub Frmlat_13_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        utama.Enabled = True
        utama.Show()
        Me.Hide()
    End Sub

    Private Sub Frmlat_13_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        utama.Enabled = True
        utama.Show()
        Me.Hide()
    End Sub
  

End Class
 

Tidak ada komentar:

Posting Komentar