|
How to calculate time difference in hours between two dates, let's say 01/01/01 12:00 and 02/02/07 7:00?
|
|
|
|
|
Just use the DateTime.Subtract function, like so:
Dim FirstDate As New DateTime(2007, 2, 2, 7, 0, 0)
Dim SecondDate As New DateTime(2001, 1, 1, 12, 0, 0)
Dim FinalDate As TimeSpan = FirstDate.Subtract(BDayNow)
Hope this helps!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
You can subtract DateTime values, the result is a TimeSpan. You can use the TotalHours property to get the time difference. Example:
Dim startTime as DateTime = new DateTime(1, 1, 1, 12, 0, 0)<br />
Dim endTime as DateTime = new DateTime(7, 2, 2, 7, 0, 0)<br />
Dim diff as TimeSpan = endTime - startTime<br />
Dim hours as Double = diff.TotalHours;
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi there,
You can use the 'DateDiff' function, realy easy to work with.
Regards, Werries
A programmer's life is good... or is it?? Ek dink nie so nie!
|
|
|
|
|
I heard on this forum that .NET 2.0 has an integrated capability to compress folders to zip file. How to use this and what is the syntax? Can you give me an example code? I would like to compress two folders "C:\temp" and "D:\foo" into a single zip-file that would be saved into "E:\zipfiles".
|
|
|
|
|
|
Hi,
I have two forms say Default.aspx and popup.aspx
Default.aspx cotains a textbox whereas popup.aspx contains a text area.
When user enters more than 10 characters in a textbox of default.aspx,popup.aspx should open and all characters of text box should get transfer to textarea of popup.aspx.
The code that i had written using javascript is as follows:
function limitText(){
var textboxvalue = document.getElementById("limitedtext").value;
if(textboxvalue.length == 10)
{
alert(textboxvalue);
window.open("popup.aspx?value=textboxvalue","","resizable=1,width=600,height=200")
}
}
And This is textbox code:
******Retrieving value in popup.aspx********
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strQuery As String = ""
strQuery = Request.QueryString("value").ToString()
TextArea1.Value = strQuery
End Sub
But When i put break point and check the value of strQuery, it is showing
"textboxvalue" instead of characters typed in the textbox.
I will be very grateful if you tell me that how should i pass the value through the url from the line:
window.open("popup.aspx?value=textboxvalue","","resizable=1,width=600,height=200")
Thanks
Shyam (new to javascript)
|
|
|
|
|
This is an ASP.NET question.
Pass the data on the URL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I want to buy vb6.0. Where can I find the cheapest and fast deal for it.
ciacia
|
|
|
|
|
The only place you're going to find VB6 is on eBay. VB6 hasn't been available for purchase retail for about 5 years now.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Can anyone tell me what is the syntex to open a HTML file in my documents? (\My Documents\123.html)
When I click on the button, I want the HTML file appear.
What's wrong with the coding below?
Dim sr As StreamReader = New StreamReader("\My Documents\123.html")
Dim line As String
Do
line = sr.ReadLine()
Console.WriteLine(line)
Loop Until line Is Nothing
sr.Close()
Thanks for your help!
|
|
|
|
|
The main problem you would have here, is that you don't have a proper path to the file. You can use Environment.SpecialFolder to get the path to the current MyDocuments folder.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't think so because the html file is located at My Documents.
May I know how to use Environment.SpecialFolder?
Thanks for your reply!
|
|
|
|
|
crazyteh wrote: I don't think so because the html file is located at My Documents.
My Documents maps into the users profile, like this:
C:\Documents and Settings\<userid>\My Documents
crazyteh wrote: May I know how to use Environment.SpecialFolder?
Sure, all you have to do is read the documentation[^] on it. It's very easy.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Like Dave said. I'll just add, if you want to be a developer, when someone tells you to use something you don't know about, try typing it into google before you ask.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I would like to acheve that when the user clicks on save form or tries to close the form,
the code would check if chkbox_otp is checked and if it is not checked than would show a msg to the user, that they must select a town from the combobox(listbox).
THANKS!!!
|
|
|
|
|
The form has a FormClosing event
Sub Form1_FormClosing(byval sender as Object, byval e as System.Windows.Forms.FormClosingEventArgs)
You can check here for your condition, if it doesn't meet your check
there are two parameters passed to this procedure.
Use the e FormClosingEventArgs
e.CancelReason="You Need to check that"
e.Cancel=True
Hope this helps.
~ CodeDoctor ~
|
|
|
|
|
Hi CodeDoctor!
Thank you for your reply.
When I click on the form I see:
Option Expilict. Below that: Privat Sub lblRefer_Click()
End Sub
Privat Sub Command1_Click()
End Sub
I have found this:
Privat Sub Form_Unload(Cancel As Integer)
---Should I put your code here maybe?---
End Sub
I don't have a Sub Form1.
I'm sorry, I am a beginner.Thanks So much!!
|
|
|
|
|
try this. Instead the code is in the Form_Load try to change it to Form_Closing.
here is the code:
if the user press the close, a message will appear.
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
dim ans
ans= MsgBox("Close this form?", MsgBoxStyle.YesNo, "Close")
if ans=MsgboxResult.Yes then
me.Close
endif
End Sub
Don't block the drive way of all the newbies in programming. )
|
|
|
|
|
hi
i have an xml file and i populated that in a treeview control.what i want is - modify the treeview like add nodes,delete nodes or edit etc and write back to the xml file/ create an xml file from that modified treeview control using vb.net
diees
|
|
|
|
|
I'm trying to read a sequential/random file written by a QBasic program, and one of the fields in the file is defined as 'Double Precision'. The field appears to be 8 bytes in length, but does not map appropriately to VB.Net 2005's Double or Long datatypes. After executing a FileGet, the double precision variable, (OrderAmount), is always filled with the wrong number.
I'm reading the record using the following logic:
Private Structure myRecordStructure
<vbfixedstring(10)> Dim FirstName As String
<vbfixedstring(15)> Dim LastName As String
<vbfixedstring(15)> Dim StreetAddress As String
<vbfixedstring(6)> Dim OrderDate As String 'MMDDYY
Dim DaysDue As Short
Dim OrderAmount As Double
End Structure
Private myRecord As myRecordStructure
mintFileNumber = FreeFile()
mstrFileName = "c:\control1.f"
FileOpen(mintFileNumber, mstrFileName, OpenMode.Random, _
OpenAccess.Read, OpenShare.Shared, Len(myRecord)
FileGet(mintFileNumber, myRecord)
Any help towards converting the QBasic double precision data to values that can be viewed from within VB.Net 2005 will be greatly appreciated.
Thanks
G-3
|
|
|
|
|
Hi
I've just started programming in VB .Net 2005, and I'm trying to
creat a datagrid that is connected to an Access database.
I want to populate the datagrid with records from Access and have fields
(with details from the same record eg. name, surname, id no.)
on the form that get populated according to the selection
in the data grid. I'm fairly new to programming so if there is anyone who
can write a concise but simple article on this, I'd really appreciate it.
Thank you.
|
|
|
|
|
try this one:
Dim objdataadapter As New SqlDataAdapter
Dim objcommand As New SqlCommand
Dim objdatatable As New DataTable
Dim objdataset As New DataSet
Dim objconn As New SqlConnection
Dim nrow As Integer
Dim strselect As String
Try
strselect = "Select * from table1"
objconn = New SqlConnection("Server=localhost; DataBase=table1; User ID=sa; pwd=")
objdataadapter.SelectCommand = New SqlCommand(strselect, objcon)
objdataadapter.Fill(objdataset)
objdatatable = objdataset.Tables(0)
If objdatatable.Rows.Count > 0 Then
DataGrid1.DataSource = objdatatable
End If
NOTE: this is optional. you can put this code
With objcommand
.Connection = objconn
.Connection.Open()
.CommandText = strselect
.CommandType = CommandType.Text
.Connection.Close()
End With
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Don't block the drive way of all the newbies in programming. )
|
|
|
|
|
I am doing a project for school and I'm trying to pull up an HTML document from a local source. My concern is that when I move the project from my HDD to a CD/ DVD the path will be incorrect and it won't be able to pull up the file. I don't want the computer to be connected to the internet to access the HTML document.
Also, I have images as backgrounds and they are not in my Resource folder according to VB. In the path they are in fact in the Resource folder. Are they going to be integrated?
Thank for any help you may be able to give.
W Lugo
|
|
|
|
|
You'd have to use relative paths for all of your file names in all of your HTML. Don't specify fully qualified paths starting with a drive letter.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|