.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Need vb.net equivalent of this line of c# code....

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
I have a line of c# that I'm looking to convert into vb.  It looks like the following:return GetFromSession("CurrentUser") as Account; "GetFromSession" is a method which returns an object. Here's the code for that method if it helps:private static object GetFromSession(string key) { if (HttpContext.Current == null || HttpContext.Current.Session == null) { return null; } return HttpContext.Current.Session[key]; } My problem is the "as Account" part of my one line of c# code needs to be converted into vb but I'm not sure of the equivalent. Currently, my vb.net won't allow it. Any idea what I should use here? Thanks  

View Complete Post

More Related Resource Links

Whats wrong with this code, im getting blue line under the createStatus next the switch

Error message: Use of unassigned local variable 'createStatus'
            MembershipCreateStatus createStatus;
            MembershipUser newUser = Membership.CreateUser(Username.Text, Password.Text, Email.Text);

            switch (createStatus)
                case MembershipCreateStatus.Success:
                    this.CreateAccountResults.Text = "The user account was successfully created!";
                case MembershipCreateStatus.DuplicateUserName:
                    this.CreateAccountResults.Text = "There already exists a user with this username.";
                case MembershipCreateStatus.DuplicateEmail:
                    this.CreateAccountResults.Text = "There already exists a user with this email address.";
                case MembershipCreateStatus.InvalidEmail:
                    this.CreateAccountResults.Text = "There email address you provided in invalid.";
                case MembershipCreateStatus.InvalidPassword:
                    this.CreateAccountResults.Text = "The password you provided is invalid. It must be seven characters long and have at least one non-a

.net 3.5 in conjunction with CRM 4.0 email router adding code to subject line of emails causing spam

We use CRM 4.0, which is using .net framework 3.5 SP 1.  Emails sent out of CRM go through and email router and the subject line of these emails is getting "=?us-ascii?Q? added to the beginning of the subject line and "?= added to the end of the subject line. This is causing a large amount of our emails getting spammed. I was told by the CRM support that this is an issue with .net 3.5 and won't be fixed until .net 4.0, which CRM won't support for another year.  Is there not a .net 3.5 patch that can address this?

Can someone please explain what this line of code is actually doing

I took this line of control from this post http://forums.asp.net/t/1201593.aspx I'm actually trying to do the same dynamic accordion.   MyAccordion.ItemDataBound += new EventHandler<AccordionItemEventArgs>(MyAccordion_ItemDataBound);    I converted to vb.net and this is the equivalent. MyAccordion.ItemDataBound += New EventHandler(Of AccordionItemEventArgs)(MyAccordion_ItemDataBound) when I type  that line in my code I get an error.. Error 3 'Public Event ItemDataBound(sender As Object, e As AjaxControlToolkit.AccordionItemEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.    and   Error 4 Delegate 'System.EventHandler(Of AjaxControlToolkit.AccordionItemEventArgs)' requires an 'AddressOf' expression or lambda  

How do I obfuscate .Net IL code using command line program?

How do I obfuscate .Net IL code using command line program? I want free tool that can be deployed to obfuscate DLL generated from compiled tool?

set the proerty from code behind line chart wpf

< Style x:Key = " InvisibleDataPointStyle " TargetType = " c:LineDataPoint " > < Setter Property = " Opacity " Value = " 0 " /> < Setter Property = " Background " Value = " Yellow " /> </ Style >

Help me modify regex code, only one line.

I have this code Dim parts As New List(Of String)(Regex.Split(RichTextBox2.Text, "~\d")) That splits lines in this format into parts: ~1Hello~2~3Bye~4~5Morning~6 So if I do MsgBox(parts(5)), it will show me "Morning". ------------------------------------------------------------------------ I want to do the exact same thing, but now my my line is arranged like this: Hello, Bye, Morning,   

SharePoint - Defaulting a Value into the obscure SharePoint:FormField controlMode=New code line

I think I've done it before somehow. but can't remember. Is there any way to force a default value into this  Markup? I've tried a few things with no luck.  Iknow i can doing in javascript codek but wanted to double check I might just not be able to force it here. The code below is binding my a column textbox to a list column while in insert mode.  Generated when I ask the DataView Designer to create a NEW button.  I just want to force the value of a querystring parameter into the column and really not even see the column. Thanks     <SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" />

Help with line of code

 Hello - Can someone explain what is happening with this piece of code. I am not sure about the "==" if (Session["_serial"] + "" == "") Response.Redirect("menu.aspx", true); Thanks,   RD

Where can i place this line of code so that its accessible thruout my entire web application?


Currently im capturing the users name during certain functions, so at the moment, i have the line below within each event that i need that information. Instead of having that line everywhere, cant iplace that line in a class or something so that i can just access it by "usn" string usn = User.Identity.Name.ToString();

disply="none" equivalent code for cs


I need disply="none" , equivalent code in cs . Because if i made visible = false then from javascript I cant access it.

So is any other way to solve that problem?

VB.Net Code Equivalent


 Hello Everyone and thanks for your help in advance.  I am trying to convert a code block into VB.Net from C# but can't get it right.  Part of the problem is the use of Static methods which I can't seem to get the equivalent.  Here is the code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;
using System.Web;

namespace RewriteModule

    public class RewriteContext
        // returns actual RewriteContext instance for
        // current request
        public static RewriteContext Current
                // Look for RewriteContext instance in
                // current HttpContext. If there is no RewriteContextInfo
                // item then this means t

Equivalent of this C# code in VB


The code in C# is as follows:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)


            //filling items in combobox1

            if (comboBox1.SelectedIndex==0)



            for (char i ='A' ; i < 'D'; i++)





            if (comboBox1.SelectedIndex == 1 || comboBox1.SelectedIndex == 2 || comboBox1.SelectedIndex == 3)



                for (char i = 'A'; i < 'E'; i++)



What is the equivalent of this razor php code?

What is the equivalent of this razor php code?

Hello friends, please, I am writing to ask for help. I am new to this programming, but Razor is quite easy. My conculta is:
Have the following code in php that generates random keys case-sensitive, letter from various nuemeros chains that varies with the value that was him of function and I would like to convert this 'razor'.cshtml, someone can help me with this?,
Thanks for the help.


function randomText($length) { 
    $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
    for($i = 0; $i < $length; $i++) { 
        $key .= $pattern{rand(0, 62)}; 
    return $key; 
$clave = randomText(5);

echo  $clave;

Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Free Code Snippets - ASP.NET

You Can Find Useful ASP.NET Related Posts on the above link.

Free Code Snippets - C#

Free C# Code Snippets

call JavaScript - jQuery code from ASP.NET Server-Side

jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend