|
--> 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.
|
|
|
|
|
Baran M wrote: 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.
Not quite true. You can use MS Access in a multiuser environment. However it can be painful to use. You can be locked out if another user is doing something with records on the same page.
The usual way is to split the database into front and back ends. The font end sits on the client PC and the back end on a server. If I remember correctly, there is a tool in the Access menu that will split an existing database.
EDIT: Added quote.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
modified on Monday, May 4, 2009 11:51 AM
|
|
|
|
|
There is all kinds of information on the web about VB.net and printing. All you have to do is Google for "vb.net printing[^]".
m2kannan wrote: is it support Ms access mutliuser operation ??
Yes, but not very well. You can run into some quirky problems and you have to make sure your code compacts the database every now then (when noone is using it!).
|
|
|
|
|
Hi,
Could anyone please help me with hiding the task bar when application runs. I did that with some code. But when I run another process from a button click, the task bar reappears. I want to disable the windows button too..
Thanks
|
|
|
|
|
You can't hide the taskbar. You CAN make your application sit on top of it, and it can also be made topmost. This is VERY hostile behaviour unless you're writing a kiosk style app.
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 )
|
|
|
|