Kamis, 17 November 2016

coddingan tugas Pak Hendrawan



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            System.Collections.Stack st = new System.Collections.Stack();

            st.Push('7');
            st.Push('8');
            st.Push('1');
            st.Push('2');
            st.Push('4');
            st.Push('9');
            st.Push('3');

            foreach (char stVarible in st)
            {
                Console.WriteLine(stVarible);
            }

            Console.WriteLine("");
            string strBil = "";
             
            var x1 = st.Pop();
            var x2 = st.Pop();
            var x3 = st.Pop();
            var x4 = st.Pop();
            var x5 = st.Pop();
            var x6 = st.Pop();
            var x7 = st.Pop();

            strBil = strBil + x5 + x4 + x1 + x3 + x7 + x6 + x2;
         
            foreach (char stVariable in st)
            {
                Console.WriteLine(stVariable);
            }
               Console.WriteLine("nilai disusun = {0}", strBil);

                }
            }

        }
 
hasil outputnya :



     
 

Aplikasi Perizinan Mobil



kali ini saya akan membuat perizinan mobil menggunakan visual basic di import ke ms. word dan ms. excel.


berikut foto form dan outputnya : 




Berikut hasil imports ke ms. word menggunakan vb




Berikut hasil imports ke ms. excel menggunakan vb


berikut adalah coddingannya


Imports Microsoft.Office.Interop

Imports word = Microsoft.Office.Interop.Word

Public Class Form1
    Dim app As New Excel.Application
    Dim book As Excel.Workbook
    Dim sheet As Excel.Worksheet
    Dim myWordApp As New word.Application
    Dim myworddoc As New word.Document
    Private Sub btnexcel_Click(sender As Object, e As EventArgs) Handles btnexcel.Click
        book = app.Workbooks.Open("‪C:\Users\ASUS\Documents\Book1.xlsx")
        sheet = book.Sheets("Sheet1")
        app.Range("A1").Value = "Nama"
        app.Range("B1").Value = "NoKtp"
        app.Range("C1").Value = "Alamat"
        app.Range("D1").Value = "Hari"
        app.Range("E1").Value = "Tanggal"
     

        app.Range("A2").Value = txtnama.Text
        app.Range("B2").Value = txtnoktp.Text
        app.Range("C2").Value = txtalamat.Text
        app.Range("D2").Value = txthari.Text
        app.Range("E2").Value = txttanggal.Text
      

        book.Save()
        app.Quit()
    End Sub

    Private Sub btnkeluar_Click(sender As Object, e As EventArgs) Handles btnkeluar.Click
        Dim a As String
        a = MsgBox("Yakin Keluar?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Konfirmasi")
        If a = vbYes Then
            Me.Close()
        End If
    End Sub

    Private Sub btnmulai_Click(sender As Object, e As EventArgs) Handles btnmulai.Click
        Me.txtnama.Text = ""
        Me.txtnoktp.Text = ""
        Me.txtalamat.Text = ""
        Me.txthari.Text = ""
        Me.txttanggal.Text = ""
        Me.txtnama.Focus()
    End Sub

    Private Sub btnword_Click(sender As Object, e As EventArgs) Handles btnword.Click
        Dim mywordapp As New word.Application
        Dim myworddoc As New word.Document
        myworddoc = mywordapp.Documents.Open("‪C:\Users\ASUS\Documents\Surat Perizinan Mobil.docx")

        myworddoc.Bookmarks("Nama").Select()
        mywordapp.Selection.Paragraphs.Alignment = word.WdParagraphAlignment.wdAlignParagraphLeft
        mywordapp.Selection.Font.Name = "Times New Roman"
        mywordapp.Selection.Font.Size = 12
        mywordapp.Selection.TypeText(txthari.Text)

        myworddoc.Bookmarks("NoKtp").Select()
        mywordapp.Selection.Paragraphs.Alignment = word.WdParagraphAlignment.wdAlignParagraphLeft
        mywordapp.Selection.Font.Name = "Times New Roman"
        mywordapp.Selection.Font.Size = 12
        mywordapp.Selection.TypeText(txttanggal.Text)

        myworddoc.Bookmarks("Alamat").Select()
        mywordapp.Selection.Paragraphs.Alignment = word.WdParagraphAlignment.wdAlignParagraphLeft
        mywordapp.Selection.Font.Name = "Times New Roman"
        mywordapp.Selection.Font.Size = 12
        mywordapp.Selection.TypeText(txttempat.Text)

        myworddoc.Bookmarks("Hari").Select()
        mywordapp.Selection.Paragraphs.Alignment = word.WdParagraphAlignment.wdAlignParagraphLeft
        mywordapp.Selection.Font.Name = "Times New Roman"
        mywordapp.Selection.Font.Size = 12
        mywordapp.Selection.TypeText(txtnama.Text)

        myworddoc.Bookmarks("Tanggal").Select()
        mywordapp.Selection.Paragraphs.Alignment = word.WdParagraphAlignment.wdAlignParagraphLeft
        mywordapp.Selection.Font.Name = "Times New Roman"
        mywordapp.Selection.Font.Size = 12
        mywordapp.Selection.TypeText(txtnpm.Text)


        myworddoc.SaveAs("‪C:\Users\ASUS\Documents\Surat Perizinan Mobil.docx")
        mywordapp.Visible = True
    End Sub

End Class