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.
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?
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()
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.
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
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.
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?
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?
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
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)
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?
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
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
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"
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).
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.
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"
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.
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.
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.
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?
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.
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.