kali ini kita mencoba oprek oprek visual studio 2012 nih ... visual studio 2012 merupakan sebuah perngkat lunak lengkap (suite) yang dapat digunakan untuk mengembangkan aplikasi , baik itu aplikasi bisnis, aplikasi personal , ataupun komponen aplikasinya , dalam bentuk aplikasi console, aplikasi windows, ataupun aplikasi web ...
kali ini saya akan membahas tentang input nilai mahasiswa ERESHA dengan menggunakan visual studio 2012 . tujuannya yaitu untuk mempermudah dosen menginput nilai mahasiswa, dan dapat lebih efektif untuk mempermudah dosen menginput nilai .
berikut contohnya :
Imports System.Data
Imports System.Data.OleDb
Imports Word = Microsoft.Office.Interop.Word
Imports Excel = Microsoft.Office.Interop.Excel
Public Class _Default
Inherits System.Web.UI.Page
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Data Sinau\Pemrograman II\nilai_mahasiswa.accdb"
Dim objekkoneksi As New OleDb.OleDbConnection(koneksi)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim G As Double
Dim S As Double
G = Val(TextBox3.Text) + Val(TextBox4.Text) + Val(TextBox5.Text)
S = G / 3
If S >= 80 Then
TextBox6.Text = "A"
ElseIf S < 80 And S >= 70 Then
TextBox6.Text = "B"
ElseIf S < 70 And S >= 60 Then
TextBox6.Text = "C"
ElseIf S < 60 Then
TextBox6.Text = "D"
End If
End Sub
Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim response As MsgBoxResult
response = MsgBox("Apakah data akan dihapus?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm")
If response = MsgBoxResult.Yes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ElseIf response = MsgBoxResult.No Then
End If
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim AppExcelnya As New Excel.Application
Dim ExcelWB As Excel.Workbook
ExcelWB = AppExcelnya.Workbooks.Open("D:\Data Sinau\Pemrograman II\Nilai_mahasiswa.xlsx")
AppExcelnya.Range("A2" + 1).Value = TextBox1.Text
AppExcelnya.Range("B2" + 1).Value = TextBox2.Text
AppExcelnya.Range("C2" + 1).Value = TextBox3.Text
AppExcelnya.Range("D2" + 1).Value = TextBox4.Text
AppExcelnya.Range("E2" + 1).Value = TextBox5.Text
AppExcelnya.Range("F2" + 1).Value = TextBox6.Text
If TextBox1.Text = "" or TextBox2.Text = "" or TextBox3.Text = "" or TextBox4.Text = "" or TextBox5.Text = "" or TextBox6.Text = "" or Then
MsgBox(" Data harus diisi semua ")
Else
ExcelWB.Save()
AppExcelnya.Visible = True
MsgBox("Data berhasil disimpan")
End If
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim Appnya As New Word.Application
Dim Dokumennya As Word.Document
Dokumennya = Appnya.Documents.Open("D:\Data Sinau\Pemrograman II\Nilai_mahasiswa.docx")
Dokumennya.Bookmarks("nik").Select()
Appnya.Selection.TypeText(TextBox1.Text)
Dokumennya.Bookmarks("nama").Select()
Appnya.Selection.TypeText(TextBox2.Text)
Dokumennya.Bookmarks("ntugas").Select()
Appnya.Selection.TypeText(TextBox3.Text)
Dokumennya.Bookmarks("nuts").Select()
Appnya.Selection.TypeText(TextBox4.Text)
Dokumennya.Bookmarks("nuas").Select()
Appnya.Selection.TypeText(TextBox5.Text)
Dokumennya.Bookmarks("gride").Select()
Appnya.Selection.TypeText(TextBox6.Text)
If TextBox1.Text = "" or TextBox2.Text = "" or TextBox3.Text = "" or TextBox4.Text = "" or TextBox5.Text = "" or TextBox6.Text = "" or Then
MsgBox(" Data harus diisi semua ")
Else
Dokumennya.SaveAs("D:\Data Sinau\Pemrograman II\Nilai_mahasiswa.docx" + TextBox1.Text)
Appnya.Visible = True
MsgBox("Data berhasil disimpan")
End If
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
objekkoneksi.Close()
objekkoneksi.Open()
Dim tambah As String = "INSERT INTO datanilai values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "') "
Dim oCmd = New OleDbCommand(tambah, objekkoneksi)
oCmd.ExecuteNonQuery()
objekkoneksi.Close()
MsgBox("Data berhasil disimpan")
End Sub
End Class
Sekian dulu yaa .. next kita coba ngoprek oprek lagi tentang visual studio