Conver VB to C#

 please convert this code to C#

 

Public Sub QuickSerach(Searchitem As Long, ByRef startdt As Date, ByRef EndDate As Date)
Dim mdate1
Dim mdate2
Dim mmonth
Dim mday
Dim myweekday


Select Case Searchitem
Case 0 'today
mdate1 = Date
mdate2 = Date
mdate1 = mdate1 + #12:00:01 AM#
mdate2 = mdate2 + #11:59:59 PM#
'Label1.Caption = mdate1
'Label2.Caption = mdate2


Case 1 'yesturday
mdate1 = Date
mdate2 = Date
mdate1 = DateAdd("d", -1, mdate1)
mdate2 = mdate1
mdate1 = mdate1 + #12:00:01 AM#
mdate2 = mdate2 + #11:59:59 PM#


Case 2 'this week
'Dim mdate1
'Dim mdate2

mdate1 = Date
myweekday = Weekday(Date)
myweekday = myweekday - 1
myweekday = myweekday * -1
mdate1 = DateAdd("d", myweekday, mdate1)
mdate1 = mdate1 + #12:00:01 AM#
mdate2 = Now


Case 3 'last week
mdate1 = Date
myweekday = Weekday(Date)
myweekday = myweekday + 7
myweekday = myweekday - 1
myweekday = myweekday * -1
mdate1 = DateAdd("d", myweekday, mdate1)
mdate1 = mdate1 + #12:00:01 AM#

myweekday = Weekday(Date)
mdate2 = Date
myweekday = myweekday * -1
mdate2 = DateAdd("d", myweekday, mdate2)
mdate2 = mdate2 + #11:59:59 PM#


Case 4 'this month

mday = Day(Date)
mday = mday - 1
mdate1 = Date
mday = mday * -1
mdate1 = DateAdd("d", mday, mdate1)
mdate1 = mdate1 + #12:00:01 AM#
mdate2 = Now

Case 5 'last month
mmonth = Month(Date)
mday = Day(Date)
mday = mday * -1

'mmonth = mmonth - 1
'mdate1
mdate2 = DateAdd("d", mday, Date)
mday = Day(mdate2)
mday = mday - 1
mday = mday * -1
mdate1 = DateAdd("d", mday, mdate2)

mdate1 = mdate1 + #12:00:01 AM#
mdate2 = mdate2 + #11:59:59 PM#



End Select

startdt = mdate1
EndDate = mdate2
End Sub
 

0
shaair
4/14/2009 7:33:04 AM
asp.net.vs2005-webapp-projects 1239 articles. 0 followers. Follow

5 Replies
714 Views

Similar Articles

[PageSpeed] 41
Get it on Google Play
Get it on Apple App Store

Use this tool  to convert from vb to c# and vice versa.

 

  1. public void QuickSerach(long Searchitem, ref System.DateTime startdt, ref System.DateTime EndDate)
  2. {
  3.     var mdate1 = null;
  4.     var mdate2 = null;
  5.     var mmonth = null;
  6.     var mday = null;
  7.     var myweekday = null;
  8.    
  9.    
  10.     switch (Searchitem) {
  11.         case 0:
  12.             //today
  13.             mdate1 = System.DateTime;
  14.             mdate2 = System.DateTime;
  15.             mdate1 = mdate1 + 01/01/0001 00:00:01;
  16.             mdate2 = mdate2 + 01/01/0001 23:59:59;
  17.             break;
  18.         //Label1.Caption = mdate1
  19.         //Label2.Caption = mdate2
  20.        
  21.        
  22.         case 1:
  23.             //yesturday
  24.             mdate1 = System.DateTime;
  25.             mdate2 = System.DateTime;
  26.             mdate1 = DateAdd("d", -1, mdate1);
  27.             mdate2 = mdate1;
  28.             mdate1 = mdate1 + 01/01/0001 00:00:01;
  29.             mdate2 = mdate2 + 01/01/0001 23:59:59;
  30.            
  31.             break;
  32.        
  33.         case 2:
  34.             //this week
  35.             //Dim mdate1
  36.             //Dim mdate2
  37.            
  38.             mdate1 = System.DateTime;
  39.             myweekday = Weekday(System.DateTime);
  40.             myweekday = myweekday - 1;
  41.             myweekday = myweekday * -1;
  42.             mdate1 = DateAdd("d", myweekday, mdate1);
  43.             mdate1 = mdate1 + 01/01/0001 00:00:01;
  44.             mdate2 = Now;
  45.            
  46.             break;
  47.        
  48.         case 3:
  49.             //last week
  50.             mdate1 = System.DateTime;
  51.             myweekday = Weekday(System.DateTime);
  52.             myweekday = myweekday + 7;
  53.             myweekday = myweekday - 1;
  54.             myweekday = myweekday * -1;
  55.             mdate1 = DateAdd("d", myweekday, mdate1);
  56.             mdate1 = mdate1 + 01/01/0001 00:00:01;
  57.            
  58.             myweekday = Weekday(System.DateTime);
  59.             mdate2 = System.DateTime;
  60.             myweekday = myweekday * -1;
  61.             mdate2 = DateAdd("d", myweekday, mdate2);
  62.             mdate2 = mdate2 + 01/01/0001 23:59:59;
  63.            
  64.             break;
  65.        
  66.         case 4:
  67.             //this month
  68.            
  69.             mday = Day(System.DateTime);
  70.             mday = mday - 1;
  71.             mdate1 = System.DateTime;
  72.             mday = mday * -1;
  73.             mdate1 = DateAdd("d", mday, mdate1);
  74.             mdate1 = mdate1 + 01/01/0001 00:00:01;
  75.             mdate2 = Now;
  76.            
  77.             break;
  78.         case 5:
  79.             //last month
  80.             mmonth = Month(System.DateTime);
  81.             mday = Day(System.DateTime);
  82.             mday = mday * -1;
  83.            
  84.             //mmonth = mmonth - 1
  85.             //mdate1
  86.             mdate2 = DateAdd("d", mday, System.DateTime);
  87.             mday = Day(mdate2);
  88.             mday = mday - 1;
  89.             mday = mday * -1;
  90.             mdate1 = DateAdd("d", mday, mdate2);
  91.            
  92.             mdate1 = mdate1 + 01/01/0001 00:00:01;
  93.             mdate2 = mdate2 + 01/01/0001 23:59:59;
  94.            
  95.             break;
  96.    
  97.    
  98.     }
  99.    
  100.     startdt = mdate1;
  101.     EndDate = mdate2;
  102. }

Joydeep Sen
Dotnet Developer

Dont forget to click “Mark as Answer” on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers


0
joydeepsen
4/14/2009 10:29:57 AM

how this line convert into C#

 

mdate1 = mdate1 + #12:00:01 AM#
mdate2 = mdate2 + #11:59:59 PM#

0
shaair
4/14/2009 11:31:30 AM

 its not working

0
shaair
4/14/2009 12:43:25 PM

shaair:
mdate1 = mdate1 + #12:00:01 AM#
mdate2 = mdate2 + #11:59:59 PM#

 

 

hi,

I think In your VB code the ## is representing the DateTime.Parse.....i am not a vb guy.........but here i think they are parsing it into teh datetime object.

try to use this and let me know what happens,

mdate1 = mdate1 + DateTime.Parse( "12:00:01");
mdate2 = mdate2 + DateTime.Parse("11:59:59");


Joydeep Sen
Dotnet Developer

Dont forget to click “Mark as Answer” on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers


0
joydeepsen
4/14/2009 12:56:12 PM

shaair:
 its not working

 

Hi shaair,

The code you have posted is not well formed. If you copy your function/sub and paste it into a VB web site page it is showing approx 20 error messages.

Also the code conversion tools has their own limitations, So i will suggest you to check with some VB guy as the fuction is not complecated enough...but it has many syntax errors.


Joydeep Sen
Dotnet Developer

Dont forget to click “Mark as Answer” on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers


0
joydeepsen
4/14/2009 1:17:58 PM
Reply:

Similar Artilces:

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Adding C# project to VB.net project
Hi All    Is it Possible to add a ASP.net C# web application to a VB.net web application project.That is here we have the main project done in VB.net , is it possible to develop a leave tracking system in Asp.Net C# and add to the main project which is devloped in VB.NET. If Possible How to Add it. Will it create any kind of complications. We are using .net 03. Thanks in advance               Thanks and regards                      Biju You should create solution for all your VB.NET pro...

vb.net and c# files in one web application projects and website project
hi,I got a bunch of files which is the source code of the application I am working on, it did not have any solution or project files. They appear to be asp.net 2.0 files, as partial classes are used.I initially added these files to a website project and I was able to run app in VS2005. My problem starts when I try and deploy application. msbuild is used to compile dependent projects, but it does not generate a dll for my web project which contains an APP_CODE folder. So my web app files cannot find the dll it needs. Precompiling is not an option my our process. Does anyone has any suggestion...

How to use VB.Net Files in C# Project and Compile All project to Only One Assembly File.?
Hi all,I have a Library of Useful Functions and procedures But in VB.Net Language(*.vb not *.dll).All the time i have to Add additional Project to my current Project and add that VB.Net Library to it ,Then Compile it and Reference it to  my C# project and use it .so as a consequence,After Compilation in the "Bin" directory i have additional assembly Related to that VB.Net Class Library rather than one.I want to know is there any way to Achieve only One Assembly Not Two. Thanks In Advance.Regards.Nothing Is Quite Impossible !!!...

C# In VB.NET project
Hello, I have product developed using VB.net. Now i want to do enhancements to it. Being very comfortable with C# do i have to learn VB.NET to make enhancements to this product. Cant i use C# to write more web forms to this project. How can i achieve that in visual studio 2005. Please Help! Imran.U and I Solutions,http://www.uandisolutions.com you can create another c# project and add it to the current project....net allow different language project in a solution but only one language inside a project www.cyberxforum.com When you use the "Add Item" feature in VS2005 to add an a...

conver c# to vb.net
Hi,   I am translating code from c# to vb.net and i am having trouble with the following C# line (in bold): <code> string pageType = (currItem is Posting ? "Posting" : "Channel"); if (!currItem.CanSetProperties) { pageType += " (read-only)"; } </code>   How is that written in vb.net? Thanks I don't really know VB but you can use an IF ELSE construct to do this. In pseudo code it would be: If currItem = "Posting" Then pageType = "Posting" Else pageType = "Channel" NB. There is an online C# to VB convert here that might be of use to you. Dim...

C# and VB .net in same project
Is there a way to have C# and VB .Net files in the same project? From my search on google, most people said you have to have two different projects although they can be in the same solution. I also saw something about creating two assemblies manually or something but didnt' really find how it's exactly done. Can someone please advise...thanks. I don't think it is actually possible to have C# and VB.Net in the same project using VS.Net. Which is why they have the project selector when you make a new project. Now, it is possible to have C# pages and VB.Net pages in the same web appli...

How can I use c# 's project web server control on a vb.net project....Help Please
Hi       I am using a server control in a C# project in an aspx file. It works fine when I use that in that same c# project. But when I import the assembly into a vb project and place the control on the page. Its giving me a System.NullReferenceException: Object reference not set to an instance of an object. error message. Please help me with it, I cant even debug it as soon as I land on the aspx page this error appears. Please help me in getting through with this message. I have spend two days working on it. Its giving me an error message on this line this.t...

Project Type From C# to VB.net
Hi, In Visual Studio 2005, till now I was working on C#, but now the project I will work is in VB.Net. So My settings are for C#. I am making a trial Project in VB.Net.  When I create a new Wesite I get the option of choosing language but when I try to make a class Project I do not see any option to create Visual Basic Project class,  only C# Project class option is available.How do I change the settings so that I can make visual Basic Project Class. Thanks, anu0987    Mark this as an answer if you find my it helpful.Thanks,Anubhuti Try Tools | Import/Export ...

Both C# and vb.net files in same project
Hi,  I have one asp.net application in vs 2005,in which i have added one C# class file in App-Code and one vb.net class file in the subfolder of App_Code.   But it is showing an error like "the file uses differnent language which is not allowed since which is need to be compiled together".Why it is showing an error like this?Plz help me..how to solve this problem?Regards,priya    Hi,take a look at this: Using VB.NET and C# in the same ASP.NET 2.0 project.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark ...

VB.net,C# project in same solution ?
Is it possible to have one vb.net and one C# projects in same solution?. One other question can we have one c# and one vb.net class in same project?ThanksArvind Is it possible to have one vb.net and one C# projects in same solution?. Sure...That's not a problem. One other question can we have one c# and one vb.net class in same project? Nope, an assembly can only have code in a single language. Thanks Xanderno .It'scrystal clear now. Arvind...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Convert VB.Net to C# with C-Sharpener For VB 1.4
C-Sharpener For VB automatically converts VB.Net projects to C# projects through a Visual Studio Add-in. It has a simple to use Wizard interface and typically converts 99%+ of the VB.Net code. You can download a free trial version. We have just released version 1.4 with several new features including an option to automatically convert non-default properties with parameters to get and set methods, support to convert On Error Goto to Try/Catch, automatic insertion of return statements to code paths with missing return statements, and more. You can find out more at http://www.elegancet...

Convert VB.Net to C# with C-Sharpener For VB 1.3
C-Sharpener For VB automatically converts VB.Net projects to C# projects through a Visual Studio Add-in. It has a simple to use Wizard interface and typically converts 99%+ of the VB.Net code. You can download a free trial version. We have just released version 1.3 which improves the conversion rate, adds a command-line interface, and more. You can find out more at http://www.elegancetech.com/csvb.aspx?src=xxx Roger Jack President Elegance Technologies, Inc. ...

Web resources about - Conver VB to C# - asp.net.vs2005-webapp-projects

Convers
生命保険 については色々と勉強するべきポイントがありますが、素人にはどの生命保険が良いのかを選ぶのが実際結構難しい場合が多いです。ですがネットの生命保険相談窓口などを活用すると、そんな面倒な生命保険に関する調べ物ものなども、簡単に終わらせることができます。

Edward Convers - Wikipedia, the free encyclopedia
He built the first house and first mill in Woburn. Convers was very active in town affairs, serving as one of its first selectmen. He served ...

Conver (@Conver) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Conver @ Conver In the land ...

Internet Archive Search: (subject:"Wyeth, Newell Convers" OR subject:"Wyeth, Newell C." OR subject:"Wyeth ...
Internet Archive Search: (subject:"Wyeth, Newell Convers" OR subject:"Wyeth, Newell C." OR subject:"Wyeth ...


Presentations ~ Stephen's Web
Stephen's Web, the home page of Stephen Downes, with news and information on e-learning, new media, instructional technology, educational design, ...

Lesbian Love - AfterEllen.com
Skip to main content Follow @afterellen TV All My Children Exes & Ohs Glee Glee Recaps Grey's Anatomy Hand Aufs Hers Interviews Lost Girl News ...

Converse Biographies
Page 101 - 107: The following is an able and correct sketch of the life of Deacon Edward Convers, and was written by Rev. Leander Thompson, of ...

AeroVironment, Inc. (AV) : About AV: Management Team
AeroVironment Inc.'s Management Team is headed by CEO Tim Conver. Other upper-management team members include Jikun Kim, Cathleen Cline, John ...

Seattle Picks: Teen - Romance
By SeattleTeenLibrarians : Love and heartbreak are the themes here. MS = middle school readers

Resources last updated: 12/14/2015 12:21:31 AM