|
Christian Graus wrote: what format do you want, specifically, or don't you care, so long as it represents a date as an int ?
yes, i don't care the format, as long as i get the int value from date value.
Example in vb6/vba:
myDate as Long
myDate = Date (2009/03/23)
so therefore myDate = 39896 (long)-->i need this in vb.net
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
OK, so ANY int value will do ? So the Ticks property I suggested you use, in my first reply, will work just fine ? DateTime.Now.Ticks
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
how to connect msaccess database in dotnet
|
|
|
|
|
a) By searching google and following the thousands of examples.
b) By reading the help manuals
c) By searching this site, i doubt you are the first to ask!
|
|
|
|
|
It took you 7 minutes here and still no direct answer. While, googling would have taken less than a minute.
जय हिंद
|
|
|
|
|
hello every one...
i want to sort particular column of Listview on click of label
for that i wrote code in label mouse click event:-
Private Sub lbl2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl2.Click
Try
Me.lst1.Sorting = SortOrder.Descending
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
but this code sorts the whole listview but i want to sort particular column
of Listview....and for that this code doesn't work...
so please suggest me what to do...
|
|
|
|
|
|
I am programming in VB.NET.
I have a csv comma delimited file with this data in it.
1212.5,10:01:56,2
1212.25,10:01:59,1
1212.5,10:02:00,1
1212.25,10:02:01,1
1212.5,10:02:04,7
1212.25,10:02:04,2
1212.5,10:02:05,2
1212.25,10:02:07,16
1212.5,10:02:10,1
1212.25,10:02:10,1
1212.5,10:02:11,1
I read the second field, which is the time field into this structure TickData(i).dTime.Str But I can't figure out how to put the hour into TickData(i).dTime.H and the minute into TickData(i).dTime.M and the seconds into TickData(i).dTime.S.
My structure's are as follow.
Structure TickTime
Dim H As Single
Dim M As Single
Dim S As Single
Dim Str As String
End Structure
Structure TickD
Dim CPrice As Double
Dim dTime As TickTime
Dim Vol As Double
End Structure
Could someone Please help!
Thank You
Gary
|
|
|
|
|
The key is the Split method.
Dim timeParts() as string
timeparts = TickData(i).dTime.Str.Split(":")
TickData(i).dTime.H = Ctype(timeParts(0), Single)
TickData(i).dTime.M = Ctype(timeParts(1), Single)
TickData(i).dTime.S = Ctype(timeParts(2), Single)
Unless there's a reason for using Single in the Structure for the time elements, you might want to save some bytes, and eliminate any possible rounding issues by using Integer or even Short.
|
|
|
|
|
Thank You very much. I will try this right away!
Gary
|
|
|
|
|
I tried it but this is the error I got.
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="TickChart"
StackTrace:
/////////////////////////////////////////////////////////////////////////////
This is how I did the loop!
Dim timeParts() As String
For i = 1 To UBound(TickData)
timeParts = TickData(i).dTime.Str.Split(":")
TickData(i).dTime.H = CType(timeParts(0), Single)
TickData(i).dTime.M = CType(timeParts(1), Single)
TickData(i).dTime.S = CType(timeParts(2), Single)
Next
|
|
|
|
|
Looks like a confusion of variable names. The object "TickChart" has apparently not been instantiated. I don't see "TickChart" anywhere in this discussion except in the unhandled exception. I may have caused the problem by using "TickData" in my code. Should that be "TickTime" instead?
|
|
|
|
|
Here is how I started
Structure TickTime
Dim H As Single
Dim M As Single
Dim S As Single
Dim Str As String
End Structure
Structure TickD
Dim CPrice As Double
Dim dTime As TickTime
Dim Vol As Double
End Structure
Public TickData() As TickD 'price data array
Then I loaded the data into TickData in a LoadData sub
Sub LoadData()
ReDim TickData(50)
end sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim timeParts() As String
For i = 1 To UBound(TickData)
timeParts = TickData(i).dTime.Str.Split(":")
TickData(i).dTime.H = CType(timeParts(0), Single)
TickData(i).dTime.M = CType(timeParts(1), Single)
TickData(i).dTime.S = CType(timeParts(2), Single)
Next
end sub
But I still get that same error from the above Bold Text!
|
|
|
|
|
1. Looks like there is a possible scope issue. Try making both of the Structures and all of their components Public. E.g.:
Public Structure TickTime
Public H As Single
Public M As Single
Public S As Single
Public Str As String
End Structure
2. All arrays in .NET are zero based. Your For...Next loop starts at 1. You might also use the .NET version for getting array bounds. With the below changes the loop will look at all 51 of the array elements.
For i = 0 To TickData.GetUpperbound(0)
3. I'm assuming there is more code in the LoadData sub other than the Redim statement. Are all 51 elements (including TickData(0)) of the TickData array being populated? If not, that could also cause the error. If there is less than 51 data records being read into the array, the size of the TickData array cannot be larger than the number of data records minus 1.
|
|
|
|
|
Thanks alot George, I was trying to read more elements than I had, which was causing the error. Now I will be using TickData.GetUpperbound(0).
Thanks again
Gary
|
|
|
|
|
|
Look into the DateTime.ParseExact function. You may also need to look into the format specifiers
|
|
|
|
|
Thanks you I will do that.
|
|
|
|
|
I am not a VB programmer.
But have to create a macro in excel sheet which uses VB code.
Actually on closing of Excel sheet i have a message box which asks to save the file.
In that i am not able to make VB code to save the file to particular location.
Can anybody provide me VB code so that i can save excel file to desired or predefined location.
I have tried some codes from net but they are not working.
Please help me out as whole module on which i am being working from one week is stuck because of this.
Thanks in advance.
|
|
|
|
|
The workbook object has a close method that has save changes parameter and a filename paramater.
Suspect you need to use that somehow.
|
|
|
|
|
Hi all...
I have created a client-server program in VB.Net to rum on LAN. Since I started my project in Windows Vista Ultimate, program run normally. Now the same program,without any changes, I tried to run on Windows XP SP2 (which have already installed VS2005), it gave an error while connecting to server. The error message is : "a socket operation was attempted to an unreachable host".
Suggest me how to solve this problem.
Thanks.
Gagan
|
|
|
|
|
Are the computers on the same networks?
Ignore your application for a moment, can you ping the target from the command prompt? If you cannot do that from windows, then your app won't see the target.
|
|
|
|
|
I'm trying to validate that all boxes are filled in by the user and not left blank.
'check for missing data
Try
Catch TitleException As Exception
If txtbxMovieTitle.Text = "" Then
MessageBox.Show("Please enter a movie title.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
With txtbxMovieTitle
.Focus()
.SelectAll()
End With
End Try
Try
Catch DataException As Exception
If radbtnDVD.Checked = False Or radbtnVHS.Checked = False Then
MessageBox.Show("Please select a movie type.", "Enter movie type", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Try
|
|
|
|
|
i think your a little confused. Within your try is where you put your logic that could cause the app to "blow up" the catch is where you want to control what happens if the blow up occurs.
Ex:
try
'do you test here
catch ex as exception
'tell the user what happened by showing the exception
msgbox(ex.tostring)
exit sub
end try
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
I've found that the simplest method for testing whether a textbox has been populated by the user is to test the length of the text.
If Textbox1.Text.Length <= 0 then
Msgbox("An entry is required in Textbox1")
Textbox1.Focus
Exit Sub
End If
If spaces are also an invalid entry, a simple addition handles that case as well.
If Textbox1.Text.Trim.Length <= 0 then
Msgbox("An entry is required in Textbox1")
Textbox1.Focus
Exit Sub
End If
|
|
|
|