Convert C# Statement To .NET?

Dec 22, 2009

convert this C# to VB.NET? convert it manually (translators are not doing a proper job for this) or at least let me know step by step what is happening in this statement so I can do the approrpriate translation myself.

async.PostOperationCompleted(
delegate(object e) { OnMyTaskCompleted((AsyncCompletedEventArgs)e); },
completedArgs);

View 4 Replies


ADVERTISEMENT

.net - Convert C# Statement Body Lambda To VB?

Oct 14, 2009

It appears that VB in VS8 doesn't support/convert lambda expressions with a statement body. I'm using them in my C# application, but now must convert it to VB.I'm creating a whole bunch of controls dynamically, and I want to be able to give them event handlers on the fly. This is so I can build a dynamic user interface from a database. In the following code I'll create a form and a checkbox, make the checkbox control the form's visibility, add a few method handlers to the form, and then add the newly created checkbox to a pre-existing form/panel/etc. Handlers for the form, for instance, affect the checkbox:

[Code]...

I really liked the ability to create everything on the fly, and then let the objects handle themselves - I don't need to add any special functions that figure out which form is giving the close event so it can search for the right checkbox and update the checkbox - It Just Works (TM).

Unfortunately it needs to be converted to VB. What is the best way to convert lambda/anonymous statement bodies into something that will work in VB, especially when one needs to create many of them?

View 2 Replies

Convert The Following VB Code To A LINQ Statement?

Oct 8, 2009

I only want to return a certain number of rows into the DataTable via LINQ's Take or use it on the Rows property, but I am not sure how or where to do it: Here is the current code:

Dim dt As DataTable = GetDataTable("sp", params)
For Each dr As DataRow In dt.Rows
Dim o As New OR()

[code].....

View 1 Replies

VS 2008 Convert SQL Statement To LINQ?

Oct 28, 2009

I'm just getting my feet wet with LINQ but am struggling to convert this SQL statement to LINQ.

Dim SQLString As String = "SELECT MESSAGE_ID FROM " & Schema & _
".PPM_TRANSFER_EMAIL WHERE TO_CHAR(IMPORTED_DATE,'YYYY/MM/DD') <= '" & _
DeletionDate.ToString("yyyy/MM/dd") & "' AND IMPORTED = 'Y' AND FILE_NAME LIKE '" & _
mb & "%'"

I have a Dataset that already contains all the data from the PPM_TRANSFER_EMAIL table so it seems silly to query the database again when I can use LINQ to query the dataset.

View 1 Replies

VS 2008 Convert MS Access Update Statement To VB?

Feb 5, 2010

converting the following MS Access Update statement into VB using VS 2008. Everytime I run this code I get error 2147217900.

UPDATE tblIEXForecast_Historical INNER JOIN SIS_daily_temp ON (tblIEXForecast_Historical.Instance = SIS_daily_temp.InstanceID) AND (tblIEXForecast_Historical.CT_ID = SIS_daily_temp.CT_ID) AND

[Code].....

View 3 Replies

Case Statement - Convert Numbers To Roman Numerals?

Mar 10, 2009

I wrote a program to convert numbers to roman numerals but something in my code is making every number I put in return a ""I" roman numeral. Here's my code.

[Code]....

View 14 Replies

SQL Statement Doesn't Work - INSERT Statement Works Fine In The Form Load But Not In The Button Click Event?

Oct 14, 2009

See

Public Class Form1
Dim sql As String
Dim conn As New OleDb.OleDbConnection
Dim da As New OleDb.OleDbDataAdapter

[CODE]...

The problem, The INSERT statement works fine in the form load but not in the button click event?

View 29 Replies

If <expression> Then <statement [:statement]> Else [statements] In Concrete Form?

Jan 1, 2010

I was convinced that If <expression> Then <statement [:statement]> Else [statements] in concrete form of If a = b Then SayHello() Else SayBye() End has sense. I read article on msdn on If-then-else, but I forgot why I was reading, so I concluded, that snippet above means this

If a = b Then HelloIsSaid : IsNotEnded Else ByeIsSaid : IsEnded But I have tested it now, and I see, that Else without statement is nothing more than decoration. It would be pretty good if it had function I described. Do you think its good request? Or do you know any circumstance where this Else has some function?

View 13 Replies

Making A Next Statement Into A Loop Statement In Visual Basic?

Jun 8, 2009

y friend and I are re-learning Visual Basic, and we are stumped on this bit of code.

For intAsterisks As Integer = 0 To intLine - 1
lblAsterisks.Text = lblAsterisks.Text + "*"
Next

View 6 Replies

Sql - Perform An Inline Select Statement In A LINQ Statement?

Jun 24, 2011

I have the following SQL:

[Code]...

I want to put it (the select count statement) in this LINQ statement so I can get the sales count in my linq statement: Dim TheLeads = (From L In DB.Leads Where L.IsDeleted = False Select L).ToList() Is this possible to do in LINQ?

View 1 Replies

Change The Exit Statement To A Continue Statement?

Feb 23, 2009

add an if statement and an exit statement to my do loop that exits when my future value (FV) is greater than 1000, then to change the exit statement to a continue statement so my loop will continue even though my fv is greater then 1000, point is to get this to run even though my if statement doesnt do anything. problem something wrong in my code and an exception error (xception of type 'System.OverflowException' occurred in mscorlib.dll)

so can someone show me where or why I have an error is, what am I overthinking now! I could use a hint, OMG i could use a tutor for that matter

[Code]...

View 3 Replies

ElseIf Statement Into A Select Case Statement?

Jun 23, 2010

A co-worker wants to convert the following IfThenElseIf statement into a Select Case statement.
Explain why this is not possible.

If temperature = 100 Then
X = 0
ElseIf population > 1000 Then
X = 1
ElseIf rate < .1 Then
X = -1
End If

View 7 Replies

SQL Statement :: Nearly Working Just Cant Get Form Values In Statement?

Aug 4, 2010

I cant get this SQL statement to insert any of the values in the form to add to the database

sql
sql = "INSERT INTO prevresults (ExamDate, ExamTime, CorrectAnswers, PassPercentage) VALUES (date.now, time.now, rightanswers, percentage.text)"

[code]....

View 4 Replies

Return Statement Which Is True In An If Statement?

May 24, 2012

Return statement which is true in an if statement

View 3 Replies

Break Up The Code In A Method Body Into Statement By Statement Symbols/"tokens"?

Apr 22, 2011

I'm writing something that will examine a function and rewrite that function in another language so basically if inside my function F1, i have this line of code var x=a.b(1) how do i break up the function body into symbols or "tokens"?I've searched around and thought that stuff in System.Reflection.MethodInfo.GetMethodBody would do the trick however that class doesn't seem to be able to have the capabilities to do what i want..dit 2:basically what I'm trying to do is to write a program in c#/vb and when i hit F5 a serializer function will (use reflection and) take the entire program (all the classes in that program) and serialize it into a single javascript file. of course javascript doesn't have the .net library so basically the C#/VB program will limit its use of classes to the .js library (which is a library written in c#/vb emulating the framework of javascript objects)

View 4 Replies

Exceptions - Can The "Throw" Statement Exist In A Block With No Try/catch Statement

Oct 5, 2009

how to use them then before, but am still a little confused with a few aspects. Here goes:

1.) Lets say you have a method that checks for a certain condition(s) and if it fails Throws an exception. Does it have to be in a try/catch block? Meaning can the "Throw" statement exist in a block with no try/catch statement?

2.) Now lets say we have a method that has a try catch block and in it there is a throw statement. When the throw statement is executed does it first try to find an appropriate catch block in the same method or does it immediately go back to the calling method without looking at the catch statements in the current method where the exception was thrown?

3.) I created a custom exception class that inherits from ApplicationException. Next I created a method which has a catch block that catches this type of exception and does some action. Is the System(i.e CLR) smart enough to throw an exception of this type, or does it only throw exceptions from SystemException?

4.) I know that some people are more liberal in their use of exceptions and others use it more sparingly when truly strange stuff happen like the DB going down. I am writing code where I am getting some info back from the database, converting it and then storing it. Sometimes there might be data that comes back from the database and other times the field is empty and the Null value comes back. Therefore in the instances where Null comes back from the database I should not convert the value to anything, since I will get an error. What should I do in this situation? Should I let the CLR throw the exception when it goes to convert the Null value or should I check for the Null value and if it exists not convert?

5.) In general when I throw exceptions, is it sensible to only throw exceptions of the type Application Exception or are there instances where the programmer throws exceptions of the type SystemException?

View 2 Replies

Make A 'like' Statement Or Use Some Kind Of Wildcard To Make The Statement Not Case Sensitive?

Jul 11, 2010

I'm building a listview search feature in my app. (See the code below). It works really well, except if you search "T" then the code removes all items, if you search "t" then it removes every item except for those starting with "t". Is there any way to make a 'like' statement, or use some kind of wildcard to make the statement not case sensitive?

For Each itm As ListViewItem In ListView2.Items
If itm.Text Like TextBox1.Text & "*" Or itm.SubItems.Item(1).Text Like TextBox1.Text & "*" Then
Else

[code].....

View 2 Replies

"End Of Statement Expected" Error In VB 2010 In A Do While Statement?

May 2, 2012

I have a line of code that is working in one statement but not the second statement. I'm not sure what I'm doing wrong, I am learning slowly but surely, and it is by no small margin because of the ave found here =) The error is occuring in the intResult = intSelection x intCount line of the SECOND Do While Loop.

The blue squiggle line is under "intCount" just FYI
Dim intSelection As Integer
Dim intCount As Integer = 0

[code]....

View 1 Replies

Components - "if" Statement Shows An Error " Statement Cannot Appear Outside Of A Method Body"

Jan 29, 2009

I have the following vb code which works as expected when it's in a code-behind page. I tried to move it to a shared or component page since I will need to use it in multiple pages:

Imports Microsoft.VisualBasic

Public
Class DetTime
'Determine eastern time

[CODE]...

However the "if" statement shows an error " statement cannot appear outside of a method body" and the Microsoft solution is to "move statement into a procedure or subroutine"

View 1 Replies

Convert - Bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16)

Feb 22, 2010

See where my vb.net equivalent of a working c# assignment statement is not working?

bytes(i / 2) = Convert.ToByte(hex.Substring(i, 1), 16)

Here's the c# followed by the vb.net function.

private byte[] StringToByteArray(String hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];

[CODE]...

And the vb.net that is throwing the error within the for loop

Private Function StringToByteArray(ByVal hex As String) As Byte()
Dim NumberChars As Int16 = CShort(hex.Length)

[CODE]...

View 2 Replies

Case Statement Inside A Case Statement

Oct 31, 2011

I have coded a case statement that changes the background colour of a panel. [code]When the code is run, it works for the case of colour1 that is NOT 1 or 2. However, when the colour1 is 1 or 2, it is supposed to pick a number from set array and run another case statement. Instead, it only picks the last value (for 1, this is 5, and for 2, this is 7).

View 3 Replies

Easier To Convert C# Asynchronous Socket Code Into .net Than Convert .net Code To C#?

Dec 8, 2009

my project was intially mandated to be done in c#.however a large contributor to the project wrote much of the business logic, which he knows well, in vb.net.How difficult would it be to convert the following c# code into vb.net.

[Code]...

View 5 Replies

"Using" Statement - "statement Cannot Appear Outside Of A Method Body"

Mar 17, 2010

Where should i put the Using statement in Visual Basic 2008 Express Edition? as i put in under general declaration, it said "statement cannot appear outside of a method body"

View 1 Replies

.net - SQL Statement In Vb?

Jan 11, 2012

I have a table named "Admin(a)"And i have a SQL statement:

SELECT *FROM Admin(a);

But (a) gives me a error.How should i express Admin(a) in a sql statement?

View 2 Replies

C# - .NET - When To Use The Using Statement

Mar 20, 2011

Dim x As New Serialization.XmlSerializer( ... )
Using file As New FileStream(myFile, FileMode.Create)
Using writer As XmlWriter = XmlTextWriter.Create(file)

[code]....

I've read that you're only supposed to use a Using block on objects that have a .Dispose() (i.e. implements IDisposable), which is why I'm thinking there shouldn't be a Using on "writer", but instead a writer.Close() at the end. But "file" has both a .Dispose() and a .Close(), so which do I use? The Using or a file.Close()?

Note: I'm using an XmlWriter because I can customize the output. I removed the settings here, though.

View 5 Replies

Cannot Get The IF Statement Right?

Aug 14, 2011

I am new to VB8 and I cannot get the IF statement right.I think I am not getting the Dim correct.I have posted before with an IF problem and this program is ok until the last IF.

[Code]...

View 12 Replies

Cannot Use Using Statement

Jun 2, 2011

I am using Visual Studio 2005 and am unable to use the "Using" statement. I have just moved some code over from a .net 4 application, but that does not seem to be the problem as it is still not usable in a new app.

[Code]...

View 2 Replies

Is There Any 'With' Statement In C#

Feb 28, 2012

Equivalence of "With...End With" in c#?So i don't know if this question has been asked before and I am not a big fan of vb.net. But one syntax that I am missing in C# is the With syntax.[code]Is there a syntax in C# that I have missed that does the same thing?

View 7 Replies

SQL Statement Using ASP And DSN?

Aug 28, 2009

I am using SQL 2005 on a Windows 2003 server. I have a database with a table called "Courses". In Courses, I have a Column called "UserChar2". In UserChar2, if left blank, does not show an image; if the letter Y is in UserChar2, it displays an image (1.gif) as the course being certified. This currently works in an XML file, the code from the XML is (##if:eq,rowquery_UserChar2,"Y","<span style="position: relative; z-index: 123; top: -40px; left: -90px; width: 80px; height: 66px; background: url(/brokered/images/1.gif) no-repeat;")

I would like to have this work in my ASP page. The code I have currently in the ASP page is (strSQLB = "SELECT Courses.UserChar2 FROM Courses WHERE Courses.UserChar2 = CASE WHEN Courses.UserChar2 = 'Y' THEN 'background: url(/1.gif) no-repeat;' END and (Courses.CampusIdentifier = '0')").

The ASP page also pulls information from the Courses table with this statement (strSQL = "SELECT Courses.CourseCode, Courses.CourseName, Courses.Course_ID, Courses.CEU, Courses.Course_Description, Courses.CertificationType, Courses.UserChar1, Courses.Notes, OrderPricing.ProductCode, OrderPricing.CampusID, OrderPricing.GroupID, OrderPricing.ProductName,

[code]....

What I would like is some help with being able to display the image using the (<% BoRs.Fields("UserChar2") %> ) code.

View 6 Replies

Use Of MOD In IIF Statement?

Jan 13, 2011

My understanding of the form of the IIF function is: MyVariable = IIF(logic test, value if true, value if false) I ran across some code that I can't understand:

bWeightOdd = IIf(bLen Mod 2, 2, 1)

The logic test in here has me stumped: bLen Mod 2 where bWeightOdd and bLen have been dimensioned as type Byte. wouldn't bLen Mod 2 just resolve to a numeric value?? I don't see a test here, merely a calculation. I don't understand how this resolves to a True or False.

View 17 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved