|
can you elaborate?
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
What I meant was, if you need to get the date difference between arrival and departure dates in terms of X years, Y months, Z weeks, and Q days then you need to write your own function.
Your function should first calculate the year difference between the arrival and departure date.
Then you need to either:
- add the years to departure date; or
- deduct the years from arrival date.
After this, you can calculate the remaining month difference between the arrival and departure date by using the modified date and so on.
Example
Departure date = 01/01/2005
Arrival date = 03/02/2006 05/03/2006
Year difference = DateDiff('y', '01/01/2005', '05/03/2006') = 1
Modified departure date = DateAdd('y', 1, '01/01/2005') = 01/01/2006
Arrival date = 03/02/2006
Months difference = DateDiff('m', '01/01/2006', '05/03/2006') = 2
...
and so on till you get the difference in days.
Got it?
Edbert
|
|
|
|
|
Edbert, How did you get the date of 05/03/2006 for a departure date...
Regards
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
Whoops.. sorry . The example arrival date was 03/02/2006 but I changed it to 05/03/2006 because I feel it's a better date example (has 1 year and 2 months difference to the departure date).
I've modified the post. You can check the modified one now.
I hope that explains it,
Edbert
|
|
|
|
|
Thanks, Thought you might like a copy of the finised product...
Dim days As Date
Dim weeks As Date
Dim months As Date
Dim years As Date
Dim numofyears As Integer
Dim numofmonths As Integer
Dim numofdays As Integer
Dim numofweeks As Integer
Dim y As Long = DateDiff(DateInterval.Year, Convert.ToDateTime(dtArrival.Text), Convert.ToDateTime(dtDeparture.Text))
years = DateAdd(DateInterval.Year, y, Convert.ToDateTime(dtArrival.Text))
numofyears = DatePart(DateInterval.Year, years) - DatePart(DateInterval.Year, Convert.ToDateTime(dtArrival.Text))
lblYears.Text = numofyears.ToString
Dim m As Long = DateDiff(DateInterval.Month, Convert.ToDateTime(dtArrival.Text), Convert.ToDateTime(dtDeparture.Text))
months = DateAdd(DateInterval.Month, m, Convert.ToDateTime(dtArrival.Text))
numofmonths = DatePart(DateInterval.Month, months) - DatePart(DateInterval.Month, Convert.ToDateTime(dtArrival.Text))
lblMonths.Text = numofmonths.ToString
Dim d As Long = DateDiff(DateInterval.Day, Convert.ToDateTime(dtArrival.Text), Convert.ToDateTime(dtDeparture.Text))
days = DateAdd(DateInterval.Day, d, Convert.ToDateTime(dtArrival.Text))
numofdays = DatePart(DateInterval.Day, days) - DatePart(DateInterval.Day, Convert.ToDateTime(dtArrival.Text))
lblDays.Text = numofdays
Regards
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
Well....it's not exactly what I had in mind.
But if that works for you then it's fine (does it work? Somehow I feel the logic isn't quite right).
My code (untested):
Dim years As Integer
Dim months as Integer
Dim days as Integer
Dim arrivalDate As Date
Dim departureDate As Date
<code>'Use variables instead of doing Convert repeatedly</code>
arrivalDate = Convert.ToDateTime(dtArrival.Text)
departureDate = Convert.ToDateTime(dtDeparture.Text)
years = DateDiff(DateInterval.Year, arrivalDate, departureDate))
lblYears.Text = years.ToString
<code>'This adds years to departure so we can get only the difference in months</code>
departureDate = DateAdd(DateInterval.Year, years, departureDate)
months = DateDiff(DateInterval.Month, arrivalDate, departureDate)
lblMonths.Text = months.ToString
<code>'This adds months to departure so we can get only the difference in days</code>
departureDate = DateAdd(DateInterval.Month, months, departureDate)
days = DateDiff(DateInterval.Day, arrivalDate, departureDate)
lblDays.Text = days
...
|
|
|
|
|
Thanks for the tips........;)
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
Hi
i have a problem with the crystal reports, in vb.net. i m not using c# as scripting language. i m using vbscript.
at the time of passing the parameter from the form(textboxes), to the crystal reprt. i m not able to do so.
And one intermediate Dialogue box is getting popped up, on which i dont have an control.
Give some preicse information about this information about it, as i have to
DEADLINE to complete this task..
Thanks
Samani Umang N.
22#Golden Jubilee
Mithpur-361345
|
|
|
|
|
|
I am new to the Visual Studio .NET world but would like to control some small ovens with this software. I am planning on using devices from Measurement Computing for my interface out to the world. Also plan on using Softwire for some of the programming. I would like to use as much code that has been already been developed. I am very interested in finding where I can get an already programmed item for PID control. Does anybody know where I can get this code?? Also where is a good place for finding free code for industrial controls???
Thanks for any help!!
|
|
|
|
|
I have created a VB webform to manage my router and wireless clients. I don't now how to submit a username and password to the login page of the router and clients (Linksys and senao web browser config). I must always do this manually. How might I code a username and password routine? Any help is appreciated. Go easy on me, I am a pre-beginner.
Thanks
Ryan
|
|
|
|
|
i want to ask u all that what is better to have more then one object of connection in a application or only one object for every transaction.
and next is what is better to close connection with database at the closing of application or when work completes with db, means i want to ask that should i open and close connection many times or better to open once and close it at the end of appli
|
|
|
|
|
|
It is generally accepted that you get the best performance when:
1) Opening a connection as late as possible
2) Closing that connection as early as possible.
in pseudo code.
Define connection
Setup queries/state etc
Open Connection
Use Connection
Close Connection
|
|
|
|
|
how to insert data in data grid in vb.net
|
|
|
|
|
Try this...
dim conn = new sqlconnection(connstring)
dim cmd = new sqlcommand
cmd.connection = conn
cmd.commandtype = command.text
cmd.commandtext = "SELECT ...."
dim da = new sqldataadapter
da.selectcommand = cmd
dim ds = new dataset
da.fill(ds, "tblname")
dg.datasource = ds.tables(0)
Feng Screwed, the art of moving to a new place because it would just be too much to clean the old place
|
|
|
|
|
I am making an FTP application that needs to have support for an UploadDir function. And I can't seem to make it work correctly. Does anyone know how to do this, or where I can get some open source FTP Class that supports uploads of Directories? I'm begging you, please help.
~Kc
|
|
|
|
|
It's no different than uploading files one at a time, because, that what you actually have to do. If your going to upload an entire directory, you have to keep track of the list of files you have to upload, the files that you've sent, and if you want, you have to track the directory tree you must create on the FTP server. If you use a simple, recursive, tree-walking algorithm on your source directory, this is easy to do.
Each iteration of the alorgithm will simply upload any files it in the current directory, then iterate through the directories in the source directory, create the folder on the FTP server, then calls itself with the new path to the new souce directory and the destination path on the FTP server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you very much Dave! I actually got this working today. The recursion was throwing me off, but I found the problem by stepping into the code slowly with the debugger. Thanks again, your answer is 100% correct.
~Kc
|
|
|
|
|
i currently has an backup of a database (called ybam) in a sql script (called c:\20053131028.sql)...
now i want to create a button where an user can restore the ybam database by click on restore button on the vb .net form....
what should i code in the button.... thank you very much....
|
|
|
|
|
heeheelim wrote:
what should i code in the button
I don't know MySql, but the process is the same for all databases so here are the steps you need to carry out.
* Load the file in to a string
* Create a Connection to the database with sufficient privileges to process your script
* Create a command object with the string of the script and the connection.
* Open() the Connection
* ExecuteNonQuery() on the command object
* Close() the connection
You may have to alter the CommandTimeout if the restore is likely to take more than 30 seconds.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Dear all,
Anyone can hide the tabpages in tabcotrol
Don't tell follows
Me.TabControl1.TabPages.Item(0).Visible = False
This is not working
And also can you draw line on tabpages
rugfy
|
|
|
|
|
On my main form is a series of text controls which are bound to a datasource (Ds1). Also on the form is a datagrid which is bound to a different datasource (Ds2). All works well.
Ds1 and Ds2 look to the same information Table (T1) and contain the exact same records. Ds2 differs, however, in that it Ds2 looks to a joined query of T1 and another Table (T2).
Question:
If I select a row from the datagrid, I want the appropriate record to appear on the main form. How can I do this?
If both the Text boxes and the Datagrid had the same underlying recordsource, the desired result would automatically occur. However, since I have two datasources, it does not happen automatically
In my code, I have successfully identified the unique counter field in T1. All I need to do is filter Ds1 or somehow move to the appropriate record on the main form.
Would I employ a data filter (e.g. Dataview)? There is NO need to clear and then re-fill Ds1 because the record is already part of the recordset. I just want to move to it on the main form.
You help and advice is greatly appreciated.
Pat
|
|
|
|
|
Hello
Have control over in the currencymanager object ,If you have give the both datasource as ds1 ,means you can work with two data source in that case u can give on click event of grid
CurrencyManager.Position = DataGrid.CureentRowIndex
Otherwise you have to explicitely assign get the Bindingcontext of Datagrid which is returned CurrencyManager/BindingManagerBase And you can control it by Move through records
Like
currencyManager.Position =0 //First
currencyManager.Position -=1 //Previous
currencyManager.Position +=1 // Next
currencyManager.Position = CurrencyManager.count - 1 //Last
Befor that You have to get the object of Bindingcontext from datagrid
Dim Cm as CurrencyManager
cm= BindingContext(Datagrid.Datasource,DataGrid.DataMember)
Now you can give that in the Mouseup by getting the hittestinfo Or Click events
private sub myDataGrid_MouseUp(byval sender as object, byval args AsMouseEventArgs )
dim hitTestInfo as DataGrid.HitTestInfo
hitTestInfo = me.myDataGrid.HitTest(args.X, args.Y)
if(hitTestInfo.Type=DataGrid.HitTestType.ColumnHeader)
// Get the CurrencyManager for the bound DataTable
CurrencyManager Cm = me.myDataGrid.BindingContext(Datagrid.DtaSource,Datagrid.Datamember)
// Get the current DataRowView
DataRowView currentRowView = (DataRowView)dataTableCurrencyManager.Current
I hope this helps you
|
|
|
|
|
hai...
everyone who know how to convert the File to String?
Actually, my idea is doing this to transfer the file to another computer. So, i convert the file (.text file or .exe file) to string and then send to another pc.
After this, the pc will received this string then convert the string to File...
So, i build up the protocol already but i dont know how to convert the file to string and the convert back from string to file.... anyone can help me.....
thanks....
|
|
|
|