Login to Website

Login dengan Facebook

 

Post Reply
Thread Tools
  #1  
Old 20th November 2011
Linuxmania
Ceriwiser
 
Join Date: Nov 2011
Posts: 392
Rep Power: 14
Linuxmania mempunyai hidup yang Normal
Default [ASK] about indexing di VB.NET

langsung aj y gan,jd gni critanya..wktu ane lg bwt prgrm aritmatik encoding dgn coding ky gni:


Spoiler for Coding form awal:




Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click

Dim i, k, n, d As Integer

Dim s, a, b As String

Dim huruf(1000) As String

Dim index(1000) As Integer

Dim var(5), prb(5) As Object



n = 0

'Penginputan nilai variabel

'pemanggilan fungsi len()

n = Len(txtInput.Text)

If n = 0 Then

MsgBox("Input Belum di isi", vbCritical, "Warning")

Exit Sub

End If

s = txtInput.Text

huruf(0) = Microsoft.VisualBasic.Left(s, 1)

index(0) = 1

For i = 0 To n

a = Microsoft.VisualBasic.Mid(s, i + 1, 1)

b = Microsoft.VisualBasic.Mid(s, i + 2, 1)

If a b Then

k = k + 1

huruf(k) = b

index(k) = 1

ElseIf a = b Then

index(k) = index(k) + 1

End If

Next

d = k

If k > 5 Then

MsgBox("Jumlah variabel lebih dari 5", vbCritical, "Warning")

Else



For i = 0 To k

var(i) = huruf(i)

prb(i) = index(i) / n


Next

Dim frm As New frmHasil()

frm.ShowDialog(frmHasil)

End If

End Sub








Spoiler for coding form hasilnya:




Dim cr As Double

Dim n, x, k As Integer

Dim s, a As String



Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click



Dim frm As New frmAwal()

frm.ShowDialog(frmAwal)

Me.Close()

End Sub



Private Sub btn_decode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click)

Dim r, cr As Double

Dim n As Integer

Dim sa As String

sa = ""

If txtDecode.Text = "" Then

MsgBox("Banyaknya decode belum di input", vbInformation, "Info")

txtDecode.Focus()

Exit Sub

End If

If txtInput.Text = "" Then

MsgBox("Encoded Value Belum Di Input", vbInformation, "Info")

txtInput.Focus()

Exit Sub

End If

'Pemindahan banyaknya decode

n = Val(txtDecode.Text)

If n = 0 Then

'Tidak ada yang di decode

MsgBox("Tidak ada yang didecode", vbInformation, "Info")

Exit Sub

End If

r = Val(txtInput.Text)

For j = 0 To 5

If r >= LBound(j) And r < UBound(j) Then

sa = sa & frmAwal.Text = var(j)

lbl_output.Text = sa

If Len(sa) = n Then

Exit Sub

End If

cr = UBound(j) - LBound(j)

r = (r - LBound(j)) / cr

End If

Next

End Sub



Private Sub btn_encode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_encode.Click



If txtInput.Text = "" Then

MsgBox("Input Masih Kosong", vbCritical, "Warning")

txtInput.Focus()

Exit Sub

End If

s = txtInput.Text

n = Len(s)

x = 0

'Fungsi Pengecekan

a = Microsoft.VisualBasic.Left(s, 1)

If a = var(0) Then

x = 1

ElseIf a = var(1) Then

x = 1

ElseIf a = var(2) Then

x = 1

ElseIf a = var(3) Then

x = 1

ElseIf a = var(4) Then

x = 1

ElseIf x = 0 Then

MsgBox("Input ada yang tidak sesuai dengan variabel", vbCritical, "Warning")

Exit Sub

Else

For i = 0 To n

x = 0

a = Microsoft.VisualBasic.Mid(s, i + 1, 1)

If a = var(0) Then

x = 1

ElseIf a = var(1) Then

x = 1

ElseIf a = var(2) Then

x = 1

ElseIf a = var(3) Then

x = 1

ElseIf a = var(4) Then

x = 1

ElseIf x = 0 Then

MsgBox("Input ada yang tidak sesuai dengan variabel", vbCritical, "Warning")

Exit Sub

End If

Next

End If

UBx = 1

LBx = 0

'Fungsi encode

For i = 1 To n

a = Microsoft.VisualBasic.Mid(s, i, 1)

For j = 0 To 4

If a = var(j) Then

cr = UBx - LBx

UBx = LBx + (cr * UBound(j))

LBx = LBx + (cr * LBound(j))

End If

Next

Next

lbl_output.Text = LBx & " - " & UBx

End Sub



Private Sub Form_Load()

Dim rangea, rangeb As String

For i = 0 To d - 1

txtVar(i).Visible = True

mnu_probabilitas(i).Visible = True

txtVar(i).Text = var(i)

mnu_probabilitas(i).Text = prb(i)

txt_range(i).Visible = True

Next

range1(0) = 0

range2(0) = prb(0)

For i = 1 To d - 1

range1(i) = range2(i - 1)

range2(i) = prb(i) + range1(i)

Next

For i = 0 To d - 1

rangea = Format(range1(i), "0.####")

rangeb = Format(range2(i), "0.####")

UBound(i) = range2(i)

LBound(i) = range1(i)

txt_range(i).Text = rangea & " - " & rangeb

Next



End Sub




Private Sub txt_ndecode_Change()

Dim x As String

'Pemerikasaan kondisi banyaknya encode

x = txtDecode.Text

Select Case x

Case "0" To "5"

'Data Diterima

Case ""

'Data diterima

Case Else

'Data Ditolak

MsgBox("Range karakter hanya 0-5", vbInformation, "Info")

txtDecode.Text = "0"

Exit Sub

End Select

End Sub







nah kayanya di bag yg merah it ad problem..keluar warning "Class 'System.Windows.Forms.TextBox' cannot be indexed because it has no default property."

dulu sempet cb d VB.6 n bisa di run..wktu it pas bwt txtboxnya udh otomatis ad indexnya..kl d VB.Net gmn y?



mhon pncerahannya para sesepuh kaskus...



nih screenshot formnya:


Spoiler for form awal:















Spoiler for form hasil:
















Terkait:
    Sponsored Links
    Space available
    Post Reply




    Switch to Mobile Mode

    no new posts