|
Try this:
New List(Of InspectionEntity)(new InspectionEntity() {element})
10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
|
|
|
|
|
Good call!
I tried
new List(Of InspectionEntity)(element)
but the compiler lied to me! lol...or at least that's my story and I'm sticking to it. My code above gave an InvalidCastException - Cannot convert type "InspectionEntity" to "IEnumerable"
When I altered it to be
new List(Of InspectionEntity)(new InspectionEntity(){element})
everything cleared itself out nicely.
"I need build Skynet. Plz send code"
|
|
|
|
|
Ok...never mind - I should have known:
The call to the constructor has to be like this:
Public Sub New(ByVal type As LocationType, ByVal element As InspectionEntity)
Me.New(type, New List(Of InspectionEntity)(element))
End Sub
Public Sub New(ByVal type As LocationType, ByVal entities As List(Of InspectionEntity))
Me.New(type, entities, New InspectionEntity([LIB].Enumerations.TableIDDefault.NullKey, "", ""))
End Sub
Note the parentheses surrounding "element" instead of curly braces...which would be the standard in every language OTHER than VB.
New problem though: The element being passed in is null, and I get an ArgumentNullException saying that the list cannot be initialized with a null object. Anyone good enough with predicates that they could provide one that could initialize the list with element if !element.Equals(null) and suppress the initialization if the argument is null....I mean..."nothing"?
I'm pretty sure that an IIF will not work in this case, but please feel free to prove me wrong!
Update: I proved myself wrong! A chained IIF works...albeit wastefully since the true and false conditions must be evaluated, but it works
Public Sub Store(ByVal type As Location.LocationType, ByVal element As InspectionEntity)
'...
If Not typeAlreadyTracked Then
'Theres no actual line-continuation '_' in my code. I only placed it here because the forum posts will not scroll horizontally.
'The code is actually much more legible in a single line
Me._locations.Add(IIf((element Is Nothing), New Location(type), New Location(type, CType(_
IIf element Is Nothing, New InspectionEntity(-999, "", ""), element), InspectionEntity))))
typeAlreadyTracked = True
End If
End Sub
Both ternary conditions in the chain are the same check
I perform an IIF(element is nothing...) and another IIF(element is nothing...) within the transverse of the initial condition
(i.e. IIF(element is nothing) - "True of False" is a tautological impossibility because it requires element to be both null and !null at the same time; which essentially provides a true ternary evaluation (albeit with the computational slowdown of a full-scan evaluation)
"I need build Skynet. Plz send code"
modified on Monday, May 4, 2009 5:40 PM
|
|
|
|
|
btw...if anyone is interested in the whole constructor chain:
Public Sub New()
Me.New(LocationType.NonDeterminant)
End Sub
Public Sub New(ByVal type As LocationType)
Me.New(type, New List(Of InspectionEntity))
End Sub
Public Sub New(ByVal type As LocationType, ByVal element As InspectionEntity)
Me.New(type, New List(Of InspectionEntity)(element))
End Sub
Public Sub New(ByVal type As LocationType, ByVal entities As List(Of InspectionEntity))
Me.New(type, entities, New InspectionEntity([LIB].Enumerations.TableIDDefault.NullKey, "", ""))
End Sub
Public Sub New(ByVal location As Location)
Me.New(location.Type, location.Entities, location.Selected)
End Sub
Public Sub New(ByVal type As LocationType, ByVal entities As List(Of InspectionEntity), ByVal selected As InspectionEntity)
Me._type = type
Me._entities = entities
Me.setSelected = IIf(selected Is Nothing, New InspectionEntity([LIB].Enumerations.TableIDDefault.NullKey, "", ""), selected)
End Sub
"I need build Skynet. Plz send code"
|
|
|
|
|
--> i am having a problem with this code...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not Me.TextBox1.Text = "a" Or Not Me.TextBox1.Text = "b" Then
MsgBox("1")
Else
MsgBox("2")
End If
End Sub
--> this code always prints "1" in da message box..
--> what is the problem?
J A Nasir K
|
|
|
|
|
If TextBox1.Text is "a" then it is not "b", thus the first condition is fulfilled. The same for TextBox1.Text being "b". Any other value will also fulfill this condition.
You probably want to exclude both "a" AND "b".
10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Jamal Abdul Nasir wrote:</div> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not Me.TextBox1.Text = "a" And Not Me.TextBox1.Text = "b" Then MsgBox("1") Else MsgBox("2") End If End Sub</blockquote>
Use And not Or
If it is not A and Not B then do something, else do something else.
------------------------------------
"Children today are tyrants. They contradict their parents, gobble their food and tyrannize their teachers. I despair for the future."
Socrates 400BC
|
|
|
|
|
Try to avoid "Not Logic". It is hard to read thus it can cause logic errors. Write you logic without the NOT operator and you will find it is much easier.
|
|
|
|
|
Try this condition
if me.textbox1.text = "a" or me.textbox1.text = "A" or me.textbox1.text = "b" or me.textbox1.text = "B" Then
MsgBox("2")
else
MsgBox("1")
end sub
|
|
|
|
|
This problem was solved hours ago. It's great you want to help people, but perhaps help people who still need help ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
On top of what Christian said, there are better ways of doing this than to make 4 conditions to check for 2 characters, while ignoring case.
|
|
|
|
|
How do I download the source code. When I open it in visual basic 2008 it's not working!?
|
|
|
|
|
|
What are you talking about?? What source code?? For what??
|
|
|
|
|
Congratulations. You're the stupidest person on these forums, at least today.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
|
:~I have a form that takes info from the user when all the entry is correct, the user can open another form for the next process.
What I mean is that let's say a registration form is open to create a registration record, when it's done, a complaint form is then open to create a complaint record based on the registration record. registration is a parent form and complaint is a child form.
the open registration record must be parsed to the complaint form for it to be opened.
the child form must be able to update the database and create a new record form its instance.
can anyone guide..
Best regard,
waner
|
|
|
|
|
Pass the 'registration' info from the parent form to the child form in the child forms constructor or property's (constructor is safest way since then you have to pass them)
Pseudo code:
class form1
private sub button1_click
'validate the registration info
if valid then
dim frm as new form2(param1,param2,...)
frm.showdialog
end if
end sub
end class
class form2
public sub new (param1 as ..., param2 as ..., ...)
initializecomponent
'do more code here with the params
end sub
end class
|
|
|
|
|
thanks,
this is what I have done.
In the registration form that is the parent form
Private sub CreateAComplaint_Click
Dim row As IGRegistrationDataSet.RegistrationRow
row = CType(CType(Me.RegistrationBindingSource.Current, DataRowView).Row, IGRegistrationDataSet.RegistrationRow)
Dim frm As New ComplaintProfile(Me.IGRegistrationDataSet, row.Reg_ID)
frm.ShowDialog()
end sub
int the complaint form that is the child form, I have this
Sub New(ByVal ds As IGRegistrationDataSet, ByVal id As Integer)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.RegistrationBindingSource.DataSource = ds
Me.RegistrationBindingSource.Filter = "Reg_ID = " & id.ToString
End Sub
* One dataset and one table..
when save on the child form nothing happens to the data base, I must go back to the parent form for the changes to occur since the child form record is in memory. I want to update the database from both the parent and the child.
**I am open to use another logic where I use seperate datasets and tables so long the child form is open from the parent..
e.i. Registration record is fine then load the complaint form to create a complaint for this particular registration..
I hope I make myslef clear..
Thanks,
Best Regard
|
|
|
|
|
I have no clear answer, but I do have some comments to help you simplify what you are doing.
0) Use a BindingSource. See documentation and walk-throughs.
1) Just pass the row. There is no need for handling the data set then filtering or anything else. You can get to the table and data set from the row.
2) Manually bind to the row using a BindingSource. In some cases, it is easier to create a class to wrap the data row and handle the business rules.
3) When user clicks okay you may have to call row.AcceptChanges. This depends on how you data bind.
4) You may want to consider overriding the ShowDialog method as in ShowDialog(row As DataRow). Usually, it is easier because it allows you some setup and clean-up. For example, ...
Private _row As DataRow
Public Overloads Sub ShowDialog(ByVal row As DataRow)
Dim iResult As DialogResult
_row = row
__bindingSource.DataSource = row
_row.BeginEdit()
'other setup
iResult = MyBase.ShowDialog
'clean-up
If iResult = System.Windows.Forms.DialogResult.OK Then
_row.AcceptChanges()
Else
_row.CancelEdit()
End If
End Sub
|
|
|
|
|
on the current form you in for example under the button
dim f as new form2
" f brings the attribute of the form you want to display the value
"me. is the current form you in so the value on the current form will go to tht next form when you click the button
f.textbox1.text = me.textbox1.text
f.showdialog this statement must be set under
|
|
|
|
|
Hi Tiyani,
Thanks a lot. I think that I am moving along. I was able to parse the textboxes record and along the primary Id key that I need to the other form..
The other form has a table that consists of the foreign key from the parent table and other columns.
so when I click save on the child form, only the records from that are pertaining to the child table and dataset get saved to the database.
Not the record I parsed from the parent table..
How can I get all the input from the form the to get saved..
Here is my my saved function to look at to see where I go wrong:
Function Save() As Boolean
Dim saved As Boolean = False
Dim errors As Integer = 0
Me.Validate()
'Parent Tables where I get the record to load the other form
Me.RegistrationBindingSource.EndEdit()
Me.RegistrationTableAdapter.Update(Me.Commission1DataSet.Registration)
'child Table
Me.Case_fileBindingSource.EndEdit()
Me.Case_fileTableAdapter.Update(Me.Case_fileDS.case_file)
Dim DeletedCaseFile As case_fileDS.case_fileDataTable = _
CType(Case_fileDS.case_file.GetChanges(Data.DataRowState.Deleted), case_fileDS.case_fileDataTable)
Dim NewCaseFile As case_fileDS.case_fileDataTable = _
CType(Case_fileDS.case_file.GetChanges(Data.DataRowState.Added), case_fileDS.case_fileDataTable)
Dim ModifiedCaseFile As case_fileDS.case_fileDataTable = _
CType(Case_fileDS.case_file.GetChanges(Data.DataRowState.Modified), case_fileDS.case_fileDataTable)
If Me.Case_fileDS.HasChanges Then
Try
If DeletedCaseFile IsNot Nothing Then
Me.Case_fileBindingSource.EndEdit()
Me.Case_fileTableAdapter.Update(DeletedCaseFile)
End If
'Parent Tables
Me.RegistrationBindingSource.EndEdit()
Me.RegistrationTableAdapter.Update(Me.Commission1DataSet.Registration)
'child Table
Me.Case_fileBindingSource.EndEdit()
Me.Case_fileTableAdapter.Update(Me.Case_fileDS.case_file)
If NewCaseFile IsNot Nothing Then
Me.Case_fileBindingSource.EndEdit()
Me.Case_fileTableAdapter.Update(NewCaseFile)
End If
If ModifiedCaseFile IsNot Nothing Then
Me.Case_fileBindingSource.EndEdit()
Me.Case_fileTableAdapter.Update(ModifiedCaseFile)
End If
Me.Case_fileDS.AcceptChanges()
'Parent Tables
Me.RegistrationBindingSource.EndEdit()
Me.RegistrationTableAdapter.Update(Me.Commission1DataSet.Registration)
'child Table
Me.Case_fileBindingSource.EndEdit()
Me.Case_fileTableAdapter.Update(Me.Case_fileDS.case_file)
Catch ex As Exception
MessageBox.Show("An error occurred during the update process")
' Add code to handle error here.
Finally
If DeletedCaseFile IsNot Nothing Then
DeletedCaseFile.Dispose()
End If
If NewCaseFile IsNot Nothing Then
NewCaseFile.Dispose()
End If
If ModifiedCaseFile IsNot Nothing Then
ModifiedCaseFile.Dispose()
End If
End Try
End If
Return True
End Function
----------------------------------------
Thanks for your continuing guidance
Best Regard,
Waner
|
|
|
|
|
hi,
i am new developer in vb.net..
i am going to print directly (without using database)
example :
while enter some values or string in text box that have to print.
this i need...
one more thing
is it support Ms access mutliuser operation ??
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
Mail To : foreverkans@gmail.com
|
|
|
|
|
please rephrase your question
|
|
|
|
|
m2kannan wrote:
is it support Ms access mutliuser operation ??
MS-Access is not a client-server software. Its just like a file If one user locks this resource nobody can access until it gets free.
|
|
|
|