oya, kepada om, akang, sesepuh semua aku mau nanya neh, /me bikin
program buat UTS, program sederhana sih, bikin calculator, terus ada
pesan errornya kayak gini Error 1 Name 'lblHasil' is not declared.
sekalian aja aku tampilan codingannya ya :
Public Class Form1
Dim HapusTampilan As Boolean
Dim Operand1, Operand2 As Double
Dim Operator1 As String
'Dim lblHasil As String
Private Sub KlikAngka(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn0.Click, btn1.Click, btn2.Click,
btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click,
btn8.Click, btn9.Click
If HapusTampilan Then
lblHasil.Text = ""
HapusTampilan = False
End If
lblHasil.Text += sender.text
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn9.Click
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn8.Click
End Sub
Private Sub btnSamaDengan_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnSamaDengan.Click
Dim Hasil As Double
Operand2 = Val(lblHasil.Text)
Try
Select Case Operator1
Case "+"
Hasil = Operand1 + Operand2
Case "-"
Hasil = Operand1 - Operand2
Case "*"
Hasil = Operand1 * Operand2
Case "/"
If Operand2 <> 0 Then
Hasil = Operand1 / Operand2
End If
End Select
lblHasil.Text = Hasil
Catch exc As Exception
MsgBox(exc.Message)
Hasil = "ERROR"
Finally
lblHasil.Text = Hasil
HapusTampilan = True
End Try
End Sub
Private Sub btnKoma_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnKoma.Click
If lblHasil.Text.IndexOf(".") > 0 Then
Exit Sub
Else
lblHasil.Text = lblHasil.Text & "."
End If
End Sub
Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnTambah.Click
Operand1 = Val(lblHasil.Text)
Operator1 = "+"
HapusTampilan = True
End Sub
Private Sub btnKurang_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnKurang.Click
Operand1 = Val(lblHasil.Text)
Operator1 = "-"
HapusTampilan = True
End Sub
Private Sub btnKali_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnKali.Click
Operand1 = Val(lblHasil.Text)
Operator1 = "*"
HapusTampilan = True
End Sub
Private Sub btnBagi_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnBagi.Click
Operand1 = Val(lblHasil.Text)
Operator1 = "/"
HapusTampilan = True
End Sub
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
If System.Char.IsDigit(e.KeyChar) Or e.KeyChar = "." Then
If HapusTampilan Then
lblHasil.Text = ""
HapusTampilan = False
End If
lblHasil.Text = lblHasil.Text + e.KeyChar
End If
If e.KeyChar = "C" Or e.KeyChar = "c" Then
lblHasil.Text = ""
End If
Select Case e.KeyChar
Case "+"
btnTambah_Click(sender, e)
Case "-"
btnKurang_Click(sender, e)
Case "*"
btnKali_Click(sender, e)
Case "/"
btnBagi_Click(sender, e)
End Select
End Sub
Private Sub btnSatuPer_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs)
If Val(lblHasil.Text) <> 0 Then
lblHasil.Text = 1 / lblHasil.Text
HapusTampilan = True
End If
End Sub
Private Sub btnNegasi_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnNegasi.Click
lblHasil.Text = -Val(lblHasil.Text)
HapusTampilan = True
End Sub
Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnHapus.Click
lblHasil.Text = ""
End Sub
Private Sub btnSin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSin.Click
lblHasil.Text = Math.Sin(CRad(lblHasil.Text))
HapusTampilan = True
End Sub
Private Sub btnCos_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCos.Click
lblHasil.Text = Math.Cos(CRad(lblHasil.Text))
HapusTampilan = True
End Sub
Private Sub btnTan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTan.Click
lblHasil.Text = Math.Tan(CRad(lblHasil.Text))
HapusTampilan = True
End Sub
Private Sub btnAkar_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAkar.Click
lblHasil.Text = Math.Sqrt(lblHasil.Text)
HapusTampilan = True
End Sub
Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLog.Click
If Val(lblHasil.Text) < 0 Then
MsgBox("Log tidak bisa dihitung pada bilangan negatif")
Else
lblHasil.Text = Math.Log10(lblHasil.Text)
End If
HapusTampilan = True
End Sub
Private Function CRad(ByVal deg)
'Konversi derajat ke radian
CRad = deg * (Math.PI / 180)
End Function
End Class
salahnya dimana ya ?? thanks
--- In [email protected], "wiequadrat" <[EMAIL PROTECTED]> wrote:
>
> Selamat atas keberhasilannya. semoga dengan ini pengetahuan nya
> bertambah.
>
> kalau ingin mulai dari baris 6 tinggal ditambah 6 dalam for next nya
>
> ===============
> for i1 = 1 + 6 to .rows-1
>
> next
> ===============
> --- In [email protected], De ce <b8880ou@> wrote:
> >
> > Pak Wie, terima kasih banyak atas bantuannya ya.... sekarang sudah
> berhasil. Ada 1 hal yang ingin saya tanyakan. Kalau perintah yang
> dibawah penulisan data di mulai dari baris 1, nah bagaimana kalau
> dimulainya dari baris ke 6 ya Pak?
> >
> > Sekali lagi terima kasih atas bantuannya :)
> >
> >
> >
> > ----- Original Message ----
> > From: wiequadrat <wiewie@>
> > To: [email protected]
> > Sent: Wednesday, February 27, 2008 8:19:25 AM
> > Subject: [indoprog-vb] Re: Tanya penjumlahan R-1
> >
> > gunakan
> > ============ ========= ==
> > with MSHFlexgrid1
> >
> > for i1=1 to .rows-1
> > XlSheet1.Cells( i1, 1).Value = trim(.textmatrix( i1, 1))
> > XlSheet1.Cells( i1, 2).Value = trim(.textmatrix( i1, 2))
> > XlSheet1.Cells( i1, 3).Value = trim(.textmatrix( i1, 3))
> > XlSheet1.Cells( i1, 4).Value = trim(.textmatrix( i1, 4))
> > XlSheet1.Cells( i1, 5).Value = trim(.textmatrix( i1, 5))
> > XlSheet1.Cells( i1, 6).Value = trim(.textmatrix( i1, 6))
> > next
> >
> > end with
> > ============ ========= ==
> >
> > NB : baris 0 itu artinya baris fixed header
> > baris 1 itu baris pertama dalam data
> > kalau ada 4 baris (termasuk 1 header) berarti looping dari 1 sampai
> 3
> > --- In indoprog-vb@ yahoogroups. com, "Didi" <dc@> wrote:
> > >
> > > Pak Wie, sepertinya ada yang slah dengan FOR-NEXT saya dechâ¦
> bisa
> > Bantu ya Pak⦠Jadi begini pada saat di simpan ke Excel file tidak
> di
> > mulai dari urutan pertama pada MSFlexGrid1 melainkan urutan ke 18.
> > >
> > > Trims sebelumnya :-)
> > >
> > >
> > >
> > > _____
> > >
> > > From: indoprog-vb@ yahoogroups. com
> > [mailto:indoprog-vb@ yahoogroups. com] On Behalf Of wiequadrat
> > > Sent: 26 Februari 2008 8:41
> > > To: indoprog-vb@ yahoogroups. com
> > > Subject: [indoprog-vb] Re: Tanya penjumlahan R-1
> > >
> > >
> > >
> > > dari coding koq kelihatannya anda masih memakai datagrid.
> > >
> > > untuk flexgrid anda cukup mengakses isi setiap cell dengan
> menggunakan
> > > fungsi TEXTMATRIX(row, col)
> > >
> > > dengan asumsi FOR-NEXT anda sudah benar
> > > ===========
> > > XlSheet1.Cells( i1, 1).Value = trim(Data1.textmatr ix(i1+11, 1))
> > > XlSheet1.Cells( i1, 2).Value = trim(Data1.textmatr ix(i1+11, 2))
> > > XlSheet1.Cells( i1, 3).Value = trim(Data1.textmatr ix(i1+11, 3))
> > > XlSheet1.Cells( i1, 4).Value = trim(Data1.textmatr ix(i1+11, 4))
> > > XlSheet1.Cells( i1, 5).Value = trim(Data1.textmatr ix(i1+11, 5))
> > > XlSheet1.Cells( i1, 6).Value = trim(Data1.textmatr ix(i1+11, 6))
> > > ===========
> > > kelihatannya data anda mulai dari baris ke 11 jadi saya +11
> > > selain trim anda juga bisa menambahkan fungsi format dsb untuk
> > > menampilkan nilai yg benar di excel.
> > >
> > > --- In indoprog-vb@ yahoogroups. com
> > <mailto:indoprog- vb%40yahoogroups .com> , "Didi" <dc@> wrote:
> > > >
> > > > Pak Wie, saya mau minta tolong 1 hal lagi yaââ¬Â¦ :-)
> > > >
> > > > Begini Pak, saya rencananya hasil dari MSFlexGrid tersebut akan
> di
> > > simpan ke Excel file, saya sudah menggunakan coding di bawah tapi
> > > selalu muncul pesan Run-time Error 1004, No current recordââ¬â¢
> > > >
> > > >
> > > >
> > > > Dim i As Integer
> > > >
> > > > Dim Row, Col, F As Long
> > > >
> > > > Dim XlApp1 As Excel.Application
> > > >
> > > > Dim XlBook1 As Excel.Workbook
> > > >
> > > > Set XlApp1 = CreateObject( "Excel.Applicati on")
> > > >
> > > > Set XlBook1 = XlApp1.Workbooks. Open("C:\ Windows\TR-
> MONTHLY.XLS" )
> > > >
> > > > Dim XlSheet1 As Excel.Worksheet
> > > >
> > > > Set XlSheet1 = XlBook1.Worksheets( 1)
> > > >
> > > >
> > > >
> > > > For i1 = 12 To Data1.Recordset. RecordCount + 11
> > > >
> > > >
> > > >
> > > > XlSheet1.Cells( i1, 1).Value = Data1.Recordset! Usr
> > > >
> > > > XlSheet1.Cells( i1, 2).Value = Data1.Recordset! TGL
> > > >
> > > > XlSheet1.Cells( i1, 3).Value = Data1.Recordset! Kode
> > > >
> > > > XlSheet1.Cells( i1, 4).Value = Data1.Recordset! Kegiatan
> > > >
> > > > XlSheet1.Cells( i1, 5).Value = Data1.Recordset! J
> > > >
> > > > XlSheet1.Cells( i1, 6).Value = Data1.Recordset! Ket
> > > >
> > > >
> > > >
> > > > Data1.Recordset. MoveNext
> > > >
> > > > Next i1
> > > >
> > > >
> > > >
> > > > XlSheet1.Applicatio n.SaveWorkspace
> > > >
> > > > XlSheet1.Applicatio n.Quit
> > > >
> > > > Set XlSheet1 = Nothing
> > > >
> > > > XlApp1.Application. Quit
> > > >
> > > > Set XlApp1 = Nothing
> > > >
> > > >
> > > >
> > > > Mohon bantuannya ya Pak dan terima kasih sekali lagi :-)
> > > >
> > > >
> > > >
> > > >
> > > > _____
> > > >
> > > >
> > > > From: indoprog-vb@ yahoogroups. com
> > <mailto:indoprog- vb%40yahoogroups .com>
> > > [mailto:indoprog-vb@ yahoogroups. com
> > <mailto:indoprog- vb%40yahoogroups .com> ] On Behalf Of wiequadrat
> > > > Sent: 25 Februari 2008 16:27
> > > > To: indoprog-vb@ yahoogroups. com
> > <mailto:indoprog- vb%40yahoogroups .com>
> > > > Subject: [indoprog-vb] Re: Tanya penjumlahan R-1
> > > >
> > > >
> > > >
> > > > sama sama. semoga berhasil juga. eh karena saya tak tahu email
> pribadi
> > > > anda jadi ada sedikit tambahan.
> > > >
> > > > pada saat anda menambahkan kontrol Flexgrid ke dalam form,
> jangan lupa
> > > > untuk "right click" flex grid nya dan pilih properties. lalu
> isi di
> > > > Columns = 7. yang lain biarkan default saja
> > > >
> > > > --- In indoprog-vb@ yahoogroups. com
> > <mailto:indoprog- vb%40yahoogroups .com>
> > > <mailto:indoprog- vb%40yahoogroups .com> , "Didi" <dc@> wrote:
> > > > >
> > > > > Terima kasih Pak Wie atas bantuannya. Saya menggunakan
> MSFlexGrid.
> > > > > Saya akan coba coding yang Bapak berikan dulu, nanti saya
> kabarkan
> > > > kembali.
> > > >
> > >
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
> >
> >
> >
> ______________________________________________________________________
> ______________
> > Be a better friend, newshound, and
> > know-it-all with Yahoo! Mobile. Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> >
> >
> > [Non-text portions of this message have been removed]
> >
>