Click here to Skip to main content
16,012,316 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: New Project Idea for Learning VB.Net Pin
Brian Lefler25-Oct-14 17:32
Brian Lefler25-Oct-14 17:32 
GeneralRe: New Project Idea for Learning VB.Net Pin
Richard MacCutchan25-Oct-14 22:20
mveRichard MacCutchan25-Oct-14 22:20 
GeneralRe: New Project Idea for Learning VB.Net Pin
Brian Lefler26-Oct-14 3:56
Brian Lefler26-Oct-14 3:56 
GeneralRe: New Project Idea for Learning VB.Net Pin
Richard MacCutchan26-Oct-14 4:34
mveRichard MacCutchan26-Oct-14 4:34 
GeneralRe: New Project Idea for Learning VB.Net Pin
Brian Lefler26-Oct-14 4:46
Brian Lefler26-Oct-14 4:46 
QuestionHelp in converting this to vb if possible Pin
jkirkerx23-Oct-14 7:26
professionaljkirkerx23-Oct-14 7:26 
AnswerI think I got it Pin
jkirkerx23-Oct-14 7:42
professionaljkirkerx23-Oct-14 7:42 
GeneralRe: I think I got it Pin
Dave Kreskowiak23-Oct-14 9:44
mveDave Kreskowiak23-Oct-14 9:44 
Keep in mind that there is no direct replacement in VB.NET for C#'s ternary operator.

What you have may work, but there is a problem. Since IF() and IIF() are both methods, ALL arguments being passed to them are evaluated. This is not true in the C# operator.

For example, if you have C# code that reads:
C#
string value = someObject.someProp == 0 ? myObject.prop + "something" : otherObject.prop


What if myObject is null when someObject.someProp does not equal 0? In C#, this wouldn't be a problem because the first return value (between the ? and colon) does not get evaluated when the statement is executed.

In the VB.NET version of the code:
VB
Dim value As String = If(someObject.someProp = 0, myObject.prop + "something", otherObject.prop)

will throw an exception because you can't return the prop property on a Nothing object (myObject).
A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: I think I got it Pin
Richard Deeming23-Oct-14 10:02
mveRichard Deeming23-Oct-14 10:02 
GeneralRe: I think I got it Pin
Dave Kreskowiak23-Oct-14 10:04
mveDave Kreskowiak23-Oct-14 10:04 
GeneralRe: I think I got it Pin
Richard Deeming23-Oct-14 10:07
mveRichard Deeming23-Oct-14 10:07 
GeneralRe: I think I got it Pin
jkirkerx23-Oct-14 10:27
professionaljkirkerx23-Oct-14 10:27 
GeneralRe: I think I got it Pin
Dave Kreskowiak23-Oct-14 15:06
mveDave Kreskowiak23-Oct-14 15:06 
GeneralRe: I think I got it Pin
Richard Deeming24-Oct-14 1:37
mveRichard Deeming24-Oct-14 1:37 
GeneralRe: I think I got it Pin
jkirkerx24-Oct-14 6:23
professionaljkirkerx24-Oct-14 6:23 
GeneralRe: I think I got it Pin
Richard Deeming24-Oct-14 6:37
mveRichard Deeming24-Oct-14 6:37 
GeneralRe: I think I got it Pin
jkirkerx24-Oct-14 6:39
professionaljkirkerx24-Oct-14 6:39 
GeneralRe: I think I got it Pin
jkirkerx24-Oct-14 6:42
professionaljkirkerx24-Oct-14 6:42 
QuestionHow to Populate DataGridViewComboBox with a DataTable Pin
Benniiit22-Oct-14 3:36
Benniiit22-Oct-14 3:36 
SuggestionRe: How to Populate DataGridViewComboBox with a DataTable Pin
Richard Deeming22-Oct-14 4:32
mveRichard Deeming22-Oct-14 4:32 
QuestionlistItem to show text box Pin
byka20-Oct-14 7:04
byka20-Oct-14 7:04 
GeneralSort methodes idees wanted Pin
JR21220-Oct-14 1:09
JR21220-Oct-14 1:09 
GeneralRe: Sort methodes idees wanted Pin
Richard Deeming20-Oct-14 1:58
mveRichard Deeming20-Oct-14 1:58 
GeneralRe: Sort methodes idees wanted Pin
Eddy Vluggen20-Oct-14 1:59
professionalEddy Vluggen20-Oct-14 1:59 
AnswerRe: Sort methodes idees wanted Pin
Manfred Rudolf Bihy20-Oct-14 2:24
professionalManfred Rudolf Bihy20-Oct-14 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.