SHARE
TWEET

Input Data Berupa Integer ke MS Excel

stevennathaniel Jan 26th, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports Excel = Microsoft.Office.Interop.Excel
  2.  
  3. Imports Microsoft.Office
  4.  
  5. Public Class Form4
  6.  
  7.     Dim appXL As Excel.Application = Nothing
  8.  
  9.     Dim wbXL As Excel.Workbook = Nothing
  10.  
  11.     Dim shXL As Excel.Worksheet = Nothing
  12.  
  13.     Dim raXL As Excel.Range = Nothing
  14.  
  15.     Dim i As Integer
  16.  
  17.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  18.  
  19.         'Source code input data dengan type data berupa integer.
  20.         'konversi dari type data string ke integer di textbox
  21.  
  22.         appXL = New Excel.Application
  23.  
  24.         wbXL = appXL.Workbooks.Open("D:\fileExcel\Latihan100.xlsx")
  25.  
  26.         shXL = wbXL.Worksheets("Sheet2")
  27.  
  28.         shXL.Activate()
  29.  
  30.         appXL.Visible = True
  31.  
  32.         i = Convert.ToInt32(TextBox1.Text)
  33.  
  34.         shXL.Cells(1, 3) = i
  35.  
  36.         appXL.UserControl = True
  37.  
  38.         raXL = Nothing
  39.  
  40.         wbXL = Nothing
  41.  
  42.         shXL = Nothing
  43.  
  44.         appXL = Nothing
  45.  
  46.         Exit Sub
  47.  
  48. Err_Handler:
  49.  
  50.         MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
  51.  
  52.  
  53.     End Sub
  54. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top