• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!

Pro 2007

Dicionario em VB

2 mensagens neste tópico

Pessoal alguem me pode olhar um pouco para este prog:

alguem me sabe explicar o que esta errado?

1 abraço

Option Strict Off
Option Explicit On
Friend Class frmMain
Inherits System.Windows.Forms.Form
Private Sub cmdDelete_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDelete.Click
	Dim strTextSearch As Object
	Dim strDelete As String

	strDelete = "Delete from Pesquisa Where Id = " & gintIdItem.Text & ""
	gAdoConn.Execute(strDelete)
	PopData((strTextSearch))
	txtWord.Text = ""
	txtMeaning.Text = ""

End Sub

Private Sub cmdNew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNew.Click
	txtWord.Text = ""
	txtMeaning.Text = ""
End Sub

Private Sub cmdSave_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSave.Click
	Dim strTextSearch As Object
	Dim strSQL As String
	Dim rs As ADODB.Recordset

	If txtWord.Text = "" Then
		MsgBox("Escreva palavras. ", MsgBoxStyle.Exclamation, "Alert")
		Exit Sub
	End If
	If txtMeaning.Text = "" Then
		MsgBox("Escreva a descrição do termo.", MsgBoxStyle.Exclamation, "Alert")
		Exit Sub
	End If

	strSQL = "Insert into Pesquisa(Termo,Descrição)Values('" & SQLSafe((txtWord.Text)) & "','" & SQLSafe((txtMeaning.Text)) & "')"
	gAdoConn.Execute(strSQL)

	PopData((strTextSearch))
	txtWord.Text = ""
	txtMeaning.Text = ""



End Sub

Private Sub cmdUpdate_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdUpdate.Click
	Dim strTextSearch As Object
	Dim strUpdate As String

	strUpdate = "Update Pesquisa Set Termo = '" & SQLSafe(txtWord.Text) & "'," & "Descrição = '" & SQLSafe(txtMeaning.Text) & "' Where Id = " & gintIdItem.Text & ""
	gAdoConn.Execute(strUpdate)
	PopData((strTextSearch))
	txtWord.Text = ""
	txtMeaning.Text = ""

End Sub

Private Sub frmMain_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
	Dim strTextSearch As Object
	Me.Text = My.Application.Info.Title
	InitConnection()
	PopData((strTextSearch))
End Sub





'UPGRADE_ISSUE: MSComctlLib.ListView event lstView.ItemClick was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="ABD9AF39-7E24-4AFF-AD8D-3675C1AA3054"'
Private Sub lstView_ItemClick(ByVal Item As System.Windows.Forms.ListViewItem)
	Dim intSelItem As Short

	intSelItem = CShort(Item.Text)

	'UPGRADE_WARNING: Lower bound of collection lstView.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
	'UPGRADE_WARNING: Lower bound of collection lstView.ListItems().ListSubItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
	txtWord.Text = lstView.Items.Item(intSelItem).SubItems.Item(1).Text
	'UPGRADE_WARNING: Lower bound of collection lstView.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
	'UPGRADE_WARNING: Lower bound of collection lstView.ListItems().ListSubItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
	txtMeaning.Text = lstView.Items.Item(intSelItem).SubItems.Item(2).Text
	'UPGRADE_WARNING: Lower bound of collection lstView.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
	'UPGRADE_WARNING: Lower bound of collection lstView.ListItems().ListSubItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
	gintIdItem.Text = lstView.Items.Item(intSelItem).SubItems.Item(3).Text



End Sub

Public Sub mnuExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuExit.Click
	End
End Sub

Private Sub InitConnection()
	Dim conDBString As String

	conDBString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & My.Application.Info.DirectoryPath & "\Pesquisa.mdb"

	gAdoConn = New ADODB.Connection
	gAdoConn.ConnectionString = conDBString
	gAdoConn.Open()

End Sub

Private Sub PopData(ByRef strTextSearch As String)

	Dim lstX As System.Windows.Forms.ListViewItem
	Dim strSQL As String
	Dim rs As ADODB.Recordset

	Dim intCounter As Short
	If strTextSearch = "" Then
		strSQL = "select * from Pesquisa Order by Termo ASC"
	Else
		strSQL = "Select * from Pesquisa Termo " & "where Termo like '%" & strTextSearch & "%' order by Termo asc"

	End If


	rs = New ADODB.Recordset
	rs.Open(strSQL, gAdoConn, 3, 1)

	lstView.Items.Clear()
	With rs
		If .RecordCount > 0 Then
			.MoveFirst()
			intCounter = 1
			While Not .EOF
				lstX = lstView.Items.Add(CStr(intCounter))
				'UPGRADE_ISSUE: MSComctlLib.ListSubItems method ListSubItems.Add was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				lstX.SubItems.Add().Text = Trim(.Fields("Termo").Value)
				'UPGRADE_ISSUE: MSComctlLib.ListSubItems method ListSubItems.Add was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				lstX.SubItems.Add().Text = Trim(.Fields("Descrição").Value)
				'UPGRADE_ISSUE: MSComctlLib.ListSubItems method ListSubItems.Add was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				lstX.SubItems.Add().Text = Trim(.Fields("Id").Value)
				intCounter = intCounter + 1
				.MoveNext()
			End While
		End If
	End With
End Sub



'UPGRADE_WARNING: Event txtSearch.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
Private Sub txtSearch_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtSearch.TextChanged
	PopData((txtSearch.Text))
End Sub
End Class

0

Partilhar esta mensagem


Link para a mensagem
Partilhar noutros sites

Crie uma conta ou ligue-se para comentar

Só membros podem comentar

Criar nova conta

Registe para ter uma conta na nossa comunidade. É fácil!


Registar nova conta

Entra

Já tem conta? Inicie sessão aqui.


Entrar Agora