Hello All,
I am doing a console application in vb.net as follows
Class Sample
Public Shared d As Integer
Public Shared m As Integer
Public Shared y As Integer
Shared Sub New()
Dim dt As DateTime = DateTime.Now
d = dt.Day
m = dt.Month
y = dt.Year
End Sub
Public Shared Sub Display()
Console.WriteLine("Day" + d + "Month" + m + "Year" + y)
End Sub
Shared Sub Main()
Sample.Display()
End Sub
End Class
The problem is in the statements
d = dt.Day
m = dt.Month
y = dt.Year
Now how can i convert the Day type into double and Month,Year into double.
Please anyone send me the code in vb.net
Thanks & Regards
Prashant S. More
Prashant MorePosted Oct 23, 2008, 5:31 AM
Thank you sir,
Thank you very for your reply my problem is completely solved.
Thank you very much.
Thanks & Regards
Prashant S. More
AlanPosted Oct 21, 2008, 9:44 AM
Just change the datatypes of 'd', 'm' and 'y' to Double. The conversion from the Integer values (dt.Day, dt.Month and dt.Year) will be automatic.
In your Console.WriteLine() statement you also need to change '+' to '&' as you're concatenating Strings rather than adding Doubles together:
Class Sample
Public Shared d As Double
Public Shared m As Double
Public Shared y As Double
Shared Sub New()
Dim dt As DateTime = DateTime.Now
d = dt.Day
m = dt.Month
y = dt.Year
End Sub
Public Shared Sub Display()
Console.WriteLine("Day" & d & " Month" & m & " Year" & y)
End Sub
Shared Sub Main()
Sample.Display()
End Sub
End Class