|
Sorry , because i'm using Database-First and I create the edmx file with wizard from an existing database. I'v tried to do what you are saying , and after I have created the model , these 2 tables are not related and ChildObjects Property does not even exist on MyObject.
|
|
|
|
|
I though you were using Code First. In your case, you have to leave the field in.
In Code First, you don't have to put that field in your model because EF will create and use the field automatically.
|
|
|
|
|
Do While sFolderName <> ""
For i = 0 To dirList.ListCount - 1
w = 1
hIcon = ExtractAssociatedIcon(App.hInstance, "C:\Windows", 3)
If sFolderName <> "" And sFolderName <> "" Then
If (GetAttr(sPath & sFolderName) And vbDirectory) = vbDirectory Then
ListView2.ListItems.add , , sFolderName, Picture2.Picture
Picture2.AutoRedraw = True
Picture2.Cls
DrawIcon Me.Picture2, 0, 0, hIcon
End If
If IsNull(hIcon) Then
picBuff.Picture = Picture2.Picture
Else
End If
sFolderName = Dir
End If
Next
ListView2.Icons = imgFiles
ListView2.SmallIcons = imgFiles
Loop
|
|
|
|
|
Hello all,
This might be a slightly basic question, but I'm trying to get into the head of a previous developer and where they were going with some unfinished code. I apologize if this is vague, but it's all I've got to work with.
Here is what I'm looking at, I've got a User Interface element that implements an interface. I'm confused as to why one would implement a Sub from an interface within a Sub in the UserInterfaceElement like this.
Any ideas?
Public Class UserInterfaceElementClass
Implements IEditableElement
Protected Sub SetupElement() Implements IEditableElement.SetupElement()
End Sub
Protected Sub UpdateObjectFromElement() Implements IEditableElement.UpdateObjectFromElement()
End Sub
End Class
Public Interface IEditableElement
Sub SetupElement()
End Sub
Sub UpdateObjectFromElement()
End Sub
End Interface
|
|
|
|
|
hilli_micha wrote: I'm confused as to why one would implement a Sub from an interface within a Sub in the UserInterfaceElement like this.
Because that's how interfaces work. I'm confused by your confusion.
An interface doesn't provide any implementation. It simply declares a contract for a type.
A class which implements the interface must provide an implementation of every member of that interface. In VB.NET, the implementation of the interface member is indicated by the Implements InterfaceName.MemberName after the member declaration.
Any class which implements an interface can be passed to any parameter, property, variable or method return declared as that interface type.
Interfaces (Visual Basic)[^]
Walkthrough: Creating and Implementing Interfaces (Visual Basic)[^]
Advantage of using Interface and Inheritance in VB.NET (OOP)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm not sure if I understood your question in the right way.
Is your question to ask for the sense of the implements-call on the method ... like answered by Richard ?
Or is your question to asked for the possible sense of in this case unused interface-method's ?
If you ask for the 2nd then it could be possible that another class could identify this class (or control) by using Reflection without knowing it's definate Type.
Perhaps you should be more specific ...
|
|
|
|
|
Ralf and Richard,
Thanks for replying. I just wanted to update you and let you know that my confusion stemmed from a lack of understanding on interfaces in themselves. I've since familiarized myself a bit better and have a grasp on the issue I was having.
Thanks!
|
|
|
|
|
Hi,
I am using Visual Studio 2010 and programming in vb. I have a txtbox name "txtFirstName" and a button called "btnCommit". Once the user has added a name to FirstName and clicked the button I need the programme to check the access database tabel to see if the name exists or not. How do I go about doing this?
Thank you in advance for your assistance.
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim inc As Integer
Dim MaxRows As Integer
Dim dbProvider As String
Dim dbSource As String
Dim MyDocumentsFolder As String
Dim TheDatabase As String
Dim FullDatabasePath As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
TheDatabase = "/AddressBook.mdb"
MyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
FullDatabasePath = MyDocumentsFolder & TheDatabase
dbSource = "Data Source = " & FullDatabasePath
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT *FROM tblContacts"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
MaxRows = ds.Tables("AddressBook").Rows.Count
inc = -1
End Sub
Private Sub NavigateRecords()
txtFirstName.Text = ds.Tables("AddressBook").Rows(inc).Item(1)
txtSurname.Text = ds.Tables("AddressBook").Rows(inc).Item(2)
cboxHouse.Checked = ds.Tables("AddressBook").Rows(inc).Item(3)
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MessageBox.Show("No More Rows")
End If
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MessageBox.Show("No Records Yet")
ElseIf inc = 0 Then
MessageBox.Show("First Record")
End If
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Item(1) = txtFirstName.Text
ds.Tables("AddressBook").Rows(inc).Item(2) = txtSurname.Text
ds.Tables("AddressBook").Rows(inc).Item(3) = cboxHouse.CheckState
da.Update(ds, "AddressBook")
MessageBox.Show("Data updated")
End Sub
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
btnCommit.Enabled = True
btnAddNew.Enabled = False
btnUpdate.Enabled = False
btnDelete.Enabled = False
txtFirstName.Clear()
txtSurname.Clear()
txtFirstName.Focus()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
inc = 0
NavigateRecords()
End Sub
Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("AddressBook").NewRow()
dsNewRow.Item("FirstName") = txtFirstName.Text
dsNewRow.Item("Surname") = txtSurname.Text
dsNewRow.Item("House") = cboxHouse.CheckState
ds.Tables("AddressBook").Rows.Add(dsNewRow)
MaxRows = MaxRows + 1
MessageBox.Show("New Record added to the Database")
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True >
btnDelete.Enabled = True
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
inc = 0
da.Update(ds, "AddressBook")
NavigateRecords()
End If
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
MessageBox.Show("Operation Cancelled")
Exit Sub
End If
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Delete()
MaxRows = MaxRows - 1
inc = 0
da.Update(ds, "AddressBook")
NavigateRecords()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Application.Exit()
End Sub
End Class
|
|
|
|
|
Just query the database for a record that contains the entered name.
|
|
|
|
|
Thank you for your response.
How do I go about doing this. I am not good at coding...
|
|
|
|
|
Member 12816539 wrote: I am not good at coding Then now would be a good time to study the documentation for the database you are using. Especially commands to insert, update and select records.
|
|
|
|
|
Hello !
In a vb.net 2013 application , I have a treeview when I need to have drag and drop operations .
But I have a case when the user begin to drag , but before drop to destination node I need to test something and if a condition is false , the entire operation should undo .
How can I do this ?
Thank you !
|
|
|
|
|
It would be easier if you showed your code, so hope this helps.
The normal process is in the DragEnter event you set e.effects = to the drag and drop you will allow (move, copy etc). Then in the DragDrop event determine your condition and set e.Effect = DragDropEffects.None if it is not allowed, else execute the drop code.
|
|
|
|
|
can i use wavelet transform to inhance but using the visual basic not math lab
i am student i donot know if i can use this way in vb
|
|
|
|
|
Sure, you just have to implement the transform yourself in code.
|
|
|
|
|
Would it be hard for someone with no programming knowledge to make an application that simply disables drag from a mouse when you hold left click or just left click in general.
With the option to hold a set key down to momentarily enable leftclick-dragging until you release the key.
|
|
|
|
|
Yes it would be very hard; especially in Visual Basic.
|
|
|
|
|
Don't worry i found a resolution. Thanks.
|
|
|
|
|
Hello !
Is there any way to use and manage an usb barcode reader in a vb.net program ?
What I want to do is :
-- Distinguish reading from barcode reader and typing from keyboard
-- Allow or deny displaying the barcode in a textbox after is read ( I mean when that textbox is focused and active at that moment )
--- Capture the barcode that is read even when no textbox is currently focused or active control at that moment ( I mean when a specific form is open , and a read from barcode reader was made , I should be able to capture the barcode in a variable )
Thank you !
Update
1) Actually , I've read somewhere on internet that to distinguish between reading from barcode reader and typing on keyboard is to keep track on keystrokes timing , for example if a stream of characters are read in less than 100ms ( or another reasonable time) then this mean a barcode reader was made. But I don't know how can I do this ?
2) About the reading in background when no textbox is focused , I've found this article : https://msdn.microsoft.com/en-us/library/ms171538%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 . Do you think that catching a barcode read at the form level , before reaching the control can help resolve this ?
modified 21-Oct-16 0:05am.
|
|
|
|
|
This has nothing to do with Visual Basic. You are asking for information on how your device works. That information should be in the manufacturer's documents.
|
|
|
|
|
We're talking for general usb barcode readers that act like a keyboard.
|
|
|
|
|
Then the same applies as for any keyboard.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, and the behaviour of the barcode reader is specific to its design & manufacture. So you still need to read the manual to see how it presents itself and its data.
|
|
|
|
|
What about programs that can work with any kind of usb barcode readers ? so they are general and what they need is only to plug the barcode reader.
|
|
|
|
|
Yes, and what happens then?
|
|
|
|