473,473 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Does anyone help me convert vb.net to c#

Function Helper(ByVal obj As Object) As String
Dim thisDate As Date = CDate(obj)
Return WeekdayName(Weekday(thisDate, vbSunday), False, vbSunday) &
"<br>" & _
thisDate.Day & "/" & thisDate.Month
End Function

(I can't find any method call Date, WeekdayName and CDate in C#. What can i
do?)
Thanks

Nov 21 '05 #1
2 2124
"Alan Ho" <gt*********@yahoo.com.hk> schrieb:
Function Helper(ByVal obj As Object) As String
Dim thisDate As Date = CDate(obj)
Return WeekdayName(Weekday(thisDate, vbSunday), False, vbSunday) &
"<br>" & _
thisDate.Day & "/" & thisDate.Month
End Function

(I can't find any method call Date, WeekdayName and CDate in C#. What can
i
do?)


Although your question is off-topic here:

'Date' -> 'DateTime'. In order to use functions like 'Weekday' and
'WeekdayName' add a reference to "Microsoft.VisualBasic.dll" and import
'Microsoft.VisualBasic.DateAndTime'. Instead of 'CDate' use
'DateTime.Parse'/'DateTime.ParseExact' or similar.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

Why would you import the Microsoft.VisualBasic namespace into C# for
functionality that is very readily available natively as part of the
..NET class library?

using System;

public class DateTest
{
public static void Test()
{
Console.WriteLine(MyDateFormat(DateTime.Now));
Console.WriteLine(MyDateFormat("1/1"));
}

public static string MyDateFormat(object obj)
{
DateTime d;
if (obj is DateTime)
{
d = (DateTime)obj;
}
else if (obj is string)
{
d = DateTime.Parse((string)obj);
}
else
{
throw new ArgumentException(obj.GetType().FullName + " no valid
for Format");
}

return d.ToString("dddd") + "<br>" + d.ToString("d/m");
}
}

Sam

On Sat, 2 Apr 2005 14:52:48 +0200, "Herfried K. Wagner [MVP]"
<hi***************@gmx.at> wrote:
"Alan Ho" <gt*********@yahoo.com.hk> schrieb:
Function Helper(ByVal obj As Object) As String
Dim thisDate As Date = CDate(obj)
Return WeekdayName(Weekday(thisDate, vbSunday), False, vbSunday) &
"<br>" & _
thisDate.Day & "/" & thisDate.Month
End Function

(I can't find any method call Date, WeekdayName and CDate in C#. What can
i
do?)


Although your question is off-topic here:

'Date' -> 'DateTime'. In order to use functions like 'Weekday' and
'WeekdayName' add a reference to "Microsoft.VisualBasic.dll" and import
'Microsoft.VisualBasic.DateAndTime'. Instead of 'CDate' use
'DateTime.Parse'/'DateTime.ParseExact' or similar.


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
4
by: Field | last post by:
Hi, the following snippet shows once executed this output: 2 2 I'd have rather expected this output: 2 10
1
by: jOs | last post by:
I wonder if anyone knows how to convert a C# Array into a JScript one. ( C# Array --> JScript.ArrayObject ? ) I have window.external on a customized C# WebBrowser, and it would be nice to get...
4
by: Garry Freemyer | last post by:
I'm trying to convert this macro to a c# function but I have a big problem. It's on the LEFT side of an assignment statement and I am extremely flustered over this one because I'm a little rusty...
1
by: Phil Sandler | last post by:
All, I come across a lot of instances where a nullable field in my database needs to be handled in the application, and I just want to set them to an empty value. For example, an integer would...
1
by: Shapper | last post by:
Hello, Does anyone knows a component to convert an Word DOC File to Adobe Acrobat PDF file? I am creating a web site where people upload word Word DOC files to the server. I need to convert...
3
by: Robin Tucker | last post by:
Does anyone have a VB.NET IPersistStream COM interface description I can cadge please? If I remember rightly, you have to "flatten" inherited COM interfaces (I think IPersistStream derives from...
29
by: Vol | last post by:
I think 'atan' can get the angle but it is not the four quadrant angle. Is there any function that i can get the angle from -pi to pi? or I have to use some if ... else? I know in Matlab, we use...
130
by: Daniel Manes | last post by:
I'm baffled. I have a column in a SQL Server Express database called "Longitude," which is a float. When I view the table in a DataGridView, some of the numbers, which only have two decimal places...
21
by: Peter Duniho | last post by:
On Fri, 18 Jul 2008 07:03:37 -0700, Ben Voigt <rbv@nospam.nospamwrote: I agree whole-heartedly about being closer to Java. But the OP didn't ask about Java. :) I disagree on the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.