|
I have two text fields:
StartTime = 20:00:00
and EndTime = 24:00:00
I am trying to check if the current time is between these two times.
I have tried:
if (StartTime.ToString() < CurrentTime) And
(CurrentTime < EndTIme.ToString()) then
'Do Something
end if
But when i go to the immediate window:
?StartTime.ToString()
returns
"System.Windows.Forms.TextBox, Text: 20:00:00"
How do I simply compare StartTime and CurrentTime?
Thanks for your help...
nju0843
|
|
|
|
|
DateTime.Compare Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDateTimeClassCompareTopic.asp
|
|
|
|
|
Nick Ueda wrote:
But when i go to the immediate window:
?StartTime.ToString()
returns
"System.Windows.Forms.TextBox, Text: 20:00:00"
You answered this yourself:
Nick Ueda wrote:
I have two text fields:
StartTime = 20:00:00
and EndTime = 24:00:00
If you want the text in the text field read the Text property:
string startTime = StartTime.Text;
|
|
|
|
|
i want to make a button on my form which will select all items in a listbox (and another button to deselect all). im not sure how to do this. also, i would like to do it with a for.. each loop, as im new to them..
not sure how to, in code, set the selecteditems (or whatever the property is, not sure which one to use).
Dim item As String
For Each item In ListBox1.Items
ListBox1.SelectedItem = ListBox1.Items.IndexOf(item)
Next is as far as iv got, but it doesnt seem to do anything.. any help appreciated
------------------------
Jordan.
III
|
|
|
|
|
First, ensure that your listbox's SelectionMode property is set to MultiSimple or MultiExtended.
Next, ListBox has a method named SetSelected which is called with 2 arguments (index and boolean "Selected")
So to select all items you could use this code:
<br />
for(int i=0;i<ListBox1.Items.Count;i++)<br />
{<br />
ListBox1.SetSelected(i,true);<br />
}<br />
|
|
|
|
|
thanks alot!
is there a way to do this with a for..each loop? using the collection of items in the listbox?
thanks again
------------------------
Jordan.
III
|
|
|
|
|
I am trying to use the generated update statements with the OleDbDataAdapter. The adapter.update works fine if the fields are maped to a datagrid. When the fields are maped to text boxes nothing is updated. Any Ideas?
|
|
|
|
|
I created an address book that uses textbox to enter information. I used the OledbAdapter because it retrieves data through MS Access. This is the way I used this creation, by using a DataForm wizard, and the MS Jet as my connection. The wizard generates the entire form and buttons that will add, delete, update, and cancel. I believe this will work in your application.
Just create MS Access blank table with all the headings that you will need to your application. Then start you vs.net and create a new instance of the form. Right click the program in the solution explorer, and click on Add New Item, then click on the DataForm and open. You will see the Wizard and just follow the instructions. Remember, the connection window will open and you will need to make a new connection by using the MS Jet, then test your connection, and you will be on your way. Hope this helps to get your application running and get updates towards your text boxes.
bravo659
|
|
|
|
|
The problem I'm having is that the update made to the Data Set is not seen by the Adapter as a modified version. I can move back and forth through the records and the changes are present in the dataset, but when I try to update the datasource nothing happens. I have tried "ending edist" but it still dosn't see the dataset as having been changed. I'm getting the same result using the OLeDB and SQl adapters.
|
|
|
|
|
This is what I currently have in my program on the update button:
It's only an example of the Contacts program.
Try
Me.BindingContext(dsContact, _
"tblContacts").EndCurrentEdit()
odaContacts.Update(dsContacts, _
"tblContacts")
Catch eSave As System.Exception
MessageBox.Show(eSave.Message)
End Try
Me.dsContacts_PositionChanged()
ReadOnlyOn()
End Sub
Now when using the DataForm wizard it will generate the entire form and coding where you don't have to do any coding, and update button clearly
updates the records perfectly. But the coding is different. So if you try
it manually with that same code it will not work unless you follow the
specified instructions of the wizard in order to get the program working.
This is what the wizard generate on the update button_Click event:
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objMyAddresses_PositionChanged()
And this address book program works like a charm, it adds records, deletes, updates, navigate back and forward to the first and last.
This is another program using the update button:
OledbDataAdapter1.Update(DataSet11.students)
DataSet11.Clear()
OledbDataAdapter1.Fill(DataSet11)
End Sub
Let me know if it works on the update button.
Remember that you must use the same context when you create the generate dataset.
|
|
|
|
|
This is what I currently have in my program on the update button:
It's only an example of the Contacts program.
Try
Me.BindingContext(dsContact, _
"tblContacts").EndCurrentEdit()
odaContacts.Update(dsContacts, _
"tblContacts")
Catch eSave As System.Exception
MessageBox.Show(eSave.Message)
End Try
Me.dsContacts_PositionChanged()
ReadOnlyOn()
End Sub
Now when using the DataForm wizard it will generate the entire form and coding where you don't have to do any coding, and update button clearly
updates the records perfectly. But the coding is different. So if you try
it manually with that same code it will not work unless you follow the
specified instructions of the wizard in order to get the program working.
This is what the wizard generate on the update button_Click event:
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objMyAddresses_PositionChanged()
And this address book program works like a charm, it adds records, deletes, updates, navigate back and forward to the first and last.
This is another program using the update button:
OledbDataAdapter1.Update(DataSet11.students)
DataSet11.Clear()
OledbDataAdapter1.Fill(DataSet11)
End Sub
Let me know if it works on the update button.
Remember that you must use the same context when you create the generate dataset.
The annonymous is me LOL
bravo659
|
|
|
|
|
I am trying to create a small program that will access a Microsoft Access Database. The program will allow it to modify the fields and add/delete records as they choose. I am creating a Visual Basic Windows Application and am setting up the OleDbDataAdapter, the OleDbDataConnection, and the DataSet. I am also setting up a Data Grid on the form to view the records. It shows everything is in tact prior to the execution and then I get the following error:
Unhandled Exception: System.Security.SecurityException: Request failed.
at connection.Form1.InitializeComponent()
I am using Microsoft Visual Studios .NET 2003
Any help would be greatfully appreciated.
Bobby
underb@d20.co.edu
|
|
|
|
|
Did you first create the MS Access database?
If you did then you can go with the OledbDataAdapter and OledbConnection.
Did you use the Microsoft Jet 4.0 for the connection? You must use the MS Jet 4.0 and test the connection in order for it to work. If not you will get the unhandled exception. When you code the program use the Try...Catch error handler to ensure that the program will not have errors.
bravo659
|
|
|
|
|
Is it possible to mask a column in a datagrid using VB.Net? I am getting either a 0 or a ten digit number. I would like to display the ten digit number as a phone number in the datagrid (ex:123-456-7899). Is this possible?
Thanks in advance,
Beginner in VB.Net
|
|
|
|
|
what do you mean by mask a column in database?
As far that I know you create your own MS Access database before you use the VB.Net to generate a dataset. I believe that you can mask any column, if not all in the MS Access. I not sure what you really mean. Could you elaborate more about masking.
bravo659
|
|
|
|
|
Well my MS Access database has one column that is NUMERIC and can only contain NUMERIC figures. For example, 5623659899 can't be 562-365-9899. There for I don't know how to take the 10 digit number and display it in a datagrid using the "-" to make it look like a telephone number. I'm not sure how to do this myself. If you want too, I can send you the project for you to look at. Just let me know.
DataGrid1 should produce
Last Phone
Red 123-456-7895 instead of --->1234567895
Blue 456-895-5698 --->4568955698
Yellow 458-652-1452 --->4586521452
Green 562-123-0258 --->5621230258
Please let me know if you want me to send you the project or if you are still unclear as to what I am trying to do.
Thanks,
Beginner in VB.Net
|
|
|
|
|
Yeah send me the application that you created and let me evaluate what you have done and I will tell you the next step to take to get the phone numbers with its format.
bravo659
|
|
|
|
|
Wondering if you already received my email with explanation in how to mask your application?
bravo659
|
|
|
|
|
Yes I did. I was able to use the imput mask in the access database and it worked when you opened access. When I pulled that column into a datagrid it didn't bring the mask with it. So it still displayed 1234567895 instead of 123-456-7895? Is there something special that I have to do in .Net to display the input mask as well?
Thanks
Tim
|
|
|
|
|
We are using async socket for our client application to connect and send/receive data from the server. It works fine for most of the time but some times we get a socket exception "An existing connection was forcibly closed by the remote host". It happens when we try to senddata to the host after connecting with host.
1. BeginConnect(remoteEP, AddressOf CallSocConnect, Me)
2. BeginSend(Data, 0, Data.Length, 0, AddressOf CallSocSend, Me)
What are the common reasons for this exception?
Is it possible that we didn't even connect with the host but we tried to send data?
Thanks for any inputs..
|
|
|
|
|
We are still having this issue, will update once its fixed.
|
|
|
|
|
hey guys! got a problem about passing an array of structure as arguments in vb.net.. i have this structure...
i have to pass an array of struct... like... Dim AccessArray(100) As AccessPointsInfo.. i just couldnt find a way....
Structure AccessPointsInfo
Dim sysIPAddress As String
Dim sysPortNumber As Integer
Dim sysAccessPointID As String
Dim sysStatus As Byte
End Structure
Private Declare Function GetAccessPointsInfo Lib "Sample.dll" (ByRef AccessPt As AccessPointsInfo) As Long
i have to pass an array of struct... like... Dim AccessArray(100) As AccessPointsInfo.. i just couldnt find a way....
|
|
|
|
|
I want to know how to use a datagrid or a flexgrid to get input from the user. Basically I nee d to get information from teh user in a matrix arrangement like a grid but I'm not sure how to use these controls to do it.
I haven't used these controls much and would gladly appreciate the help;)
|
|
|
|
|
OK here's the situation. Say we have a whole bunch of equations in the database. EG: "A + B * C". Now we get the equation and substitute values into it so we now have a string like "10 + 5 * 3".
Is it possible now to evaluate this expression without having to break the whole string into itty bitty pieces to work with? Is there some magic Execute(equation) function in .NET?
Thanks,
Nic
The man who smiles when things go wrong has thought of someone he can blame it on.
If you tell a man there are 300 billion stars in the universe, he'll believe you. But if you tell him a bench has just been painted, he'll have to touch it to be sure.
|
|
|
|
|
Nic Rowan wrote:
to break the whole string into itty bitty pieces
Isn't that called parsing?
Nic Rowan wrote:
Is there some magic Execute(equation) function in .NET?
Not really. However someone did post a project that does what you want, although it is in C#, it could easily be rewritten for VB.NET. Runtime C# Expression Evaluator[^]. I would guess that the line that sets up the C# Compiler could easily be changed to a VB.NET compiler.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|