Nullable Syntax Accepts C# Shorthand?
Jun 14, 2010
By accident i put in some C# shorthand synthax in a vb.net project, and to my suprise, it compiled and runs fine! Does anyone know if this was a framework update? I can't find any documentation that points this out
The following Vb.net code works fine for me
Dim someDate As DateTime? = Nothing
If someDate.HasValue Then
Console.WriteLine(someDate.Value)
End If
View 2 Replies
ADVERTISEMENT
Nov 18, 2010
Possible Duplicate:Is there a conditional ternary operator in VB.NET? Is there a version of the shorthand If-Then-Else in C#:[code]
View 2 Replies
Jan 20, 2009
Is there a VB.net equivalent to the C#:
public string FirstName { get; set; }
I know you can do
Public Property name() As String
Get
Return _name.ToString
[code].....
But I can't seem to google up an answer on a vb shorthand.
View 5 Replies
Mar 30, 2010
Currently, I have code similar to this:
xxx, _
If(dr.Table.Columns.Contains("EnterpriseID"), dr.Field(Of Integer)("EnterpriseID"), -1), _
xxx
I would like to create a Lamdba expression something like the following (this doesn't work):
Dim xCol As Func(Of DataRow, String, Type, Object, Object) = _
Function(dr, x, t, dflt) _
If(dr.Table.Columns.Contains(x), dr.field(Of t)(x), dflt)
So that I can say something like:
xxx, _
xCol(dr, "EnterpriseID", GetType(System.Integer), -1), _
xxx
View 1 Replies
Mar 25, 2010
This is hopefully a softball syntax question: I need to call a method with an empty Object array for evaluation and set initial state. In C# I would just do this:
func(new Object[]{});
In VB.NET I am forced to do this:
Dim ctrls() As Control = {}
func(ctrls)
Is there a way to shorthand the call in VB.NET and have everything happen in one line of code?
View 2 Replies
Feb 7, 2012
I'm working with Ticks a lot at the moment and when setting a timespan/similar, I find the shorthand exponent notation 3e6 far more easy to read at a glance than 3000000
VS converts to the long form as soon as it tidies up the line.
Is there any way to turn off the editor feature which reformats this?
View 1 Replies
Mar 3, 2011
So I'm just trying to understand why someone would want to use the shorthand property instantiation
Public Property CarModel As String <-- property
As opposed to
Public CarModel As String <-- variable
View 19 Replies
Sep 17, 2009
I accidently wrote some code today that was like this[code]...
I immediately noticed the issue, but I had already hit the run button. It compiled successfully, I ran it through to the section and it threw an exception.
You can't do this in C#, it gives a compile error "cannot convert from 'int?' to 'int'".
Is there an 'Option Explicit' type switch that I can turn on to ensure that this sort of error does not occur again?
View 1 Replies
Oct 12, 2011
I am having an issue trying to figure this out. I am writing a script editor that uses tabs (a tab control) and I want to implement syntax highlighting. My issue is that every sample I can find on syntax highlighting uses
Private Sub RichTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
View 1 Replies
Sep 28, 2010
I'm trying to write a program that accepts a word and then determinesif the letters in it is in alphabetical order. There will be a message if it is, like with the words almost, imply, abcd and so on. However, if the letters are not in alphabetical order, another message will show.
View 18 Replies
Aug 15, 2009
here's the code
Public Class Prelim1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mile, inches, centimeter, foot, kilometers As Double
mile = TextBox1.Text
[code]....
notice the textbox1.text, it should only accept a double. IF the user inputs letter or whatever characters then the program must prompt a message which reads "input only a number"
View 5 Replies
Aug 31, 2011
how to check browser state in asp.netot detrimine if a usersbrowser accepts cookies?
View 3 Replies
Feb 9, 2010
I am trying to create a standard procedure, which accepts a parameter:
Public
Sub
CreateWC(ByVal
dtWC As
DataTable )
...
...
...
End
Sub
View 8 Replies
Mar 5, 2010
Is there a way to use a generic that only accepts integer types?
I have a Clamp(value, min, max) function, and it would be nice if it could accept ints, uints, floats, shorts, ect without having to write an individual function for each type.
View 1 Replies
Sep 28, 2010
I have a MaskedTB whose mask is "000 Years 00 Months". I have read the documentation for the mask and for '0' in the mask it says
Quote:
Digit, required. This element will accept any single digit between 0 and 9 Then why is it accepting space
View 6 Replies
Sep 9, 2009
the Threading.Interlocked class provides; I don't understand, though, why the Add function only offers two overloads: one for Integers, another for Longs. Why not Doubles, or any other numeric type for that matter?Clearly, the intended method for changing a Double is CompareExchange; I am GUESSING this is because modifying a Double is a more complex operation than modifying an Integer.
View 4 Replies
May 28, 2009
Can anyone tell me if the Imports System.IO accepts all files types?? What I mean is, can I use it to access .csv, .xls or .doc files? And one other thing.Do I need to include the file location in the body of the procedure/function??
View 18 Replies
May 29, 2010
I am trying to make a calculator that accepts multiple operations, similar to the calculator found on Windows.
View 6 Replies
Mar 26, 2009
I got an error:Error 1 Overload resolution failed because no accessible 'AddtblLokasjonRow' accepts this number of arguments.[code]
View 15 Replies
Mar 4, 2010
I have a text box that accepts an 8 digit hex encrypted string and adds it to a listbox1. Then I have a button that when clicked takes the string from listbox1 and
1) reverses the string
2) subtracts 235
3) Converts it back to a 9 digit number
4) Adds it to listbox2 using the
Private Sub decrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles decrypt.Click
Dim i As Integer
Dim buffer As String = ListBox1.Items(i)[code].....
However something seems to be wrong because it get an arithmetic overflow exception.
View 2 Replies
Feb 14, 2012
Are there any web hosting packages that accepts a website, a mysql database, and a system created in vb.net.This is my thesis project. Both website and system's database are connected to each other. It means that when I add a user using the system, the user that I added must be able to login on my website.
View 1 Replies
Nov 6, 2010
Trying to create a program that accepts a square array size 4 by 4. Then it should print the totals of the rows and columns. I started with a form and made text boxes and created a print button. I made it so that numbers can be input into the boxes. When hitting the print button, it should print the totals of what was input, however, it isn't doing that. Is there a different way to write the array code so that it will print it? Should i not have text boxes but rather have labels with fixed numbers set in them?
View 11 Replies
Nov 8, 2011
develop an application which accepts a positive integer value from the user and outputs the sum of all integers between 0 and the given integer.
View 7 Replies
Jul 5, 2011
I'm trying to make a main menu which accepts user input and then checks inputted password for validity against passwords I hardcoded into an array. Firstly, in the for loop, only the first password index is being checked. I'd like the inputted password to be checked against EACH password inside the ValidPasswords() array.
Second, My for loop isn't doing what I want it to do. I'd like to give the user 3 chances to enter a password... If he/she exceeds 3, it tells them they've tried 3 times and exits the form. Right now, it just loops 3 times and exits without giving the user a chance to try again. If I put a return statement in, it just keeps returning and doesn't loop 3 times.
Public Class frmMain
Dim ValidPasswords() = {"1234", "2222", "8918", "9911"}
'Dim ValidPWList As New List(Of String)
[Code]......
View 1 Replies
Apr 1, 2012
I'm getting a very odd problem with a conversion from C# to VB (VB10 - .NET 4 target):
C#: IEnumerable<string> test = new string[] { "abc", "def", "ghi" };
int i = test.Count<string>();
VB:Dim test As IEnumerable(Of String) = New String() { "abc", "def", "ghi" }
Dim i As Integer = test.Count(Of String)()
the last line results in a compile error "overload resolution failed because no accessible 'Count' accepts this number of type arguments"
[Code]...
View 18 Replies
Aug 1, 2011
I need the code to filter the data entered in a textbox. Although it accepts all the characters during runtime, the code should remove all the strings and alpha numeric characters except the numbers (which would be my output). I tried the following code but guess it won't do:
a = Textbox1.text
Dim value As Decimal = CDec(Regex.Replace(a, "[D]", ""))
View 3 Replies
May 16, 2011
I am developing a VB.NET application with SQL Server 2008 and I get the above error when I try to run this ASPX file. What is the cause?
[Code]...
View 1 Replies
Jun 4, 2009
Suppose I want to write a function like the following (as usual, a trivial example for illustrative purposes):
Public Function calcSqSum(Of T)(ByVal list As IEnumerable(Of T)) As T
Dim sumSq As T
For Each item As T In list
[Code]....
As you can probably guess, this function causes an error because a generic object is not guaranteed to implement the + operator. As far as I know, though, any numerical type (Integer, Double, Decimal, etc.) will.
Is there a way to write a (quasi-)generic function that can accept any numerical type, without having to explicitly overload the function for every such type yourself?
Alternatively, I suppose an equally acceptable solution would be to somehow check if a type implements the '+' operator (or any operator generally associated with numerical types and used by the function).
View 4 Replies
Mar 12, 2009
I'm trying to create a program which accepts a letter of the alphabet. For each letter a corresponding word beginning with that letter should be output, e.g., �a� or �A� input would give Alpha as the output, �b� or �B� would give Bravo and so on to �z� or �Z� giving Zulu.So if the user enters: "abc" for example, what should happen is a list on the right of the window appears with the words starting with those letters when the user presses calculate.I don't have any code apart form the basics below.
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
[code]....
View 7 Replies
Jul 28, 2009
I have a Linq to SQL dbml file in a vb2008 project ... which the following line exists:
Dim dbDocuments As New DocumentsDataContext
View 2 Replies