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
ADVERTISEMENT
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
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
Oct 7, 2011
Im trying to figure how to use the IF, ELSE statements OR the Select Case statement to write this program.I'm using Visual Studio 2010. The program is suppose to allow the user to input their weight in a text box and from group box 1 the select whether theyre male or female using the radios and they select inactive or active from group box two and the calculate but will determine how many calories they should intake based on the criteria below.
[Code]...
View 14 Replies
Jan 29, 2010
I was rooting around in one of our company apps which is done in VB.net. I'm not familiar with VB.net (I do stuff in C#) so I'm asking this question: Does the code after the clean up comment execute? [code]It is my understanding once you say return, you give the calling function control again.
View 6 Replies
Mar 22, 2011
I have a form that contains multiple conditional or if statements on several defferent for controls.
Example: Radio Buttons, TextBoxes and CheckBoxes.
I am intending to create an order form(demo) where the user can select multiple products.
I have a default order number that changes by one everytime an order is successful.
An order is only successful if all the information on the form is entered correctly.
My question is where do I insert the code for the order number?
Basically for the order number I have a counter that count by increment of one if an order is successful.
Meaning when the user hit place order, and all the infromation is right, then the order numer goes to 1 from zero.
Where do I add the condition for the order number since all the fields must first be completed.
Do I have to create a whole line of if else statements?
View 5 Replies
Dec 1, 2010
I want to display an image if 2 conditions are met. The data item is not null. The value of the data item is greater than 0 Markup
<img id="Img1" runat="server" visible='<%#IIF( DataBinder.Eval(Container.DataItem, "amount") is DBNull.Value Or DataBinder.Eval(Container.DataItem, "amount") = 0, False, True)%>' src="/Images/check.png" />
Error message: Operator '=' is not defined for type 'DBNull' and type 'Integer'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Operator '=' is not defined for type 'DBNull' and type 'Integer'.
View 1 Replies
Feb 26, 2009
I want to extract
[code]...
using a regular expression. I have a regex like this:
FROM.*order
which extracts FROM codes WHERE FieldName='ContactMethod' and IsNull(Deactived,'') != 'T' order Also, how can I get rid of the capitalization?
View 4 Replies
Mar 23, 2009
I have a requirement where I have to add items into a List(Of T) (let's call it Target) from an IEnumerable(Of T) (let's call it Source) using Target.AddRange() in VB.NET.
Target.AddRange(Source.TakeWhie(Function(X, Index) ?))
The ? part is a tricky condition that is something like: As long as the as yet unenumerated count is not equal to what is needed to fill the list to the minimum required then randomly decide if the current item should be taken, otherwise take the item.Somethig like...
Source.Count() - Index = _minimum_required - _curr_count_of_items_taken _
OrElse GetRandomNumberBetween1And100() <= _probability_this_item_is_taken
' _minimum_required and _probability_this_item_is_taken are constants
The confounding part is that _curr_count_of_items_taken needs to be incremented each time the TakeWhile statement is satisfied. How would I go about doing that? I'm also open to a solution that uses any other LINQ methods (Aggregate, Where, etc.) instead of TakeWhile.If all else fails then I will go back to using a good old for-loop =)
View 2 Replies
Apr 11, 2011
[Code]....
This code is giving an error: Compiler Error Message: BC30201: Expression expected. I just basically want to check if two values are equal but its saying something about expression expected although i've given the expression to evaluate.
View 2 Replies
Jan 20, 2012
I have a class with a static list of keys, and I have a static method called Remove() that removes a key from that list.Now what I understand from the contracts post conditions is that as the programmer of the class, I guarantee that the current public method does something specific, in this case : removing the element of the list.
Here's what I've written:
private static List<Keys> m_usedKeys; // private list of keys
public static void Remove(Keys _key)
{
[code]....
What I'm trying to "Ensure" here, is that the Remove() method removes the key for real from the list (Yes this might be a trivial example, but I get the error there.)when I write the Contract.Ensures() line, VS2010 gives me the following error :
Error 3 Detected expression statement evaluated for potential side-effect in contracts of method 'LibJungleTimer.KeyBind.Remove(System.Windows.Forms.Keys)'. (Did you mean to put the expression into a Requires, Ensures, or Invariant call?) C:UsersJoelDocumentsProgrammationJTJungleTimerLibJungleTimerKeyBind.cs 51
I think this error says that the expression m_usedKeys.remove(_key); has a potential side-effect. In fact, it has a side-effect, it removes a key from the list!If I try to write something like this instead :
Contract.Assert(!m_usedKeys.Any(x => x == _key));
well it compiles fine.
View 1 Replies
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
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
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
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
Dec 9, 2011
Now I have a sub to validate a bunch of textboxes and combo boxes.I previously used many IF statements to validate and pop up different messageboxes and Exit Sub in every IF statement.But I heard that too many Exits will decrease the efficiency and they were not recommended to use. Instead, nested IF is better because it will let the process naturally go to the end.Then I found out that if I use nested IF,it will be hard to read, since messageboxes are all separated from conditions.
View 2 Replies
May 24, 2012
Return statement which is true in an if statement
View 3 Replies
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
Jun 26, 2009
The 'reader' within the if statement is showing "Expression is not a method", what am I doing wrong?
[Code]...
View 2 Replies
Feb 18, 2011
Why can I do the following :
Dim qNodes As IQueryable(Of XmlNode) = xDoc.ChildNodes.AsQueryable()
Dim test = qNodes.Where(Function(node) True)
although the following gives the error I stated in the title :
Dim qNodes As IQueryable(Of XmlNode) = xDoc.ChildNodes.AsQueryable()
Dim test = qNodes.Where(Function(node)
Return True
End Function)
View 3 Replies
Oct 31, 2011
I'm looking to find the nearest number to 5 in the column row and order it so closest is at the top. Here is what I got....
[Code]...
View 2 Replies
Oct 1, 2010
I have a custom timer that acts like a Wait for some number of milliseconds and then execute a function. It looks like this:
Public Class MyTimer
Inherits Timers.Timer
Public Event Done()
[code]....
(So, every one second, Timer checks if TextBox1 is empty. If it isn't, it displays a message box and stops checking.)I get a warning that Timer is used before it has been assigned a value, but it is used in the statement that assigns its value. The timer's interval is required to be greater than zero.
View 2 Replies
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
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
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
Dec 26, 2009
How would I be able to avoid using the imports statements on each form of the project?
i.e. just using the statements on the main form
Imports System
Imports System.IO
View 2 Replies
Aug 19, 2009
I don't see why this code is not running. I want the form to be hided if the statement is true, but what it does is only open the other form but not hide this one.
Dim fileExists As Boolean
fileExists = My.Computer.FileSystem.FileExists("C: est est.tx")
If fileExists = True Then[code].....
View 9 Replies
Dec 24, 2010
Why can't I start a line using a parenthesis followed by the keyword new?? For example:
(New <custom_obj>).foo(var) In that case is obvious that I'm trying to avoid creating a named instance of the the <custom_obj> because I know that I'll only be using it at that sentence.
Note that actually creating a named instance is not a problem for me... I just wanna know the reason why this is not possible.
View 1 Replies
Dec 11, 2009
In my new application i have to process a SQL statement.Depending on the settings , the statement takes between 10 an 20 seconds.is there a possibility to display a second from / dialog / popup for this time?
View 5 Replies
Dec 2, 2010
How do I(Can I) code a conditional statement in a TableAdapter query? I have a product code which can be either 8 or 9 characters long. Product codes are stored in an Access 2003 db table. I need to group products so in Access I have a simple Function which work fine in a Jet SQL query. But I can't get it to work in VB 2005.
Public Function ProdCats(ByVal Prod as string)
Dim Cat as string = Len(Prod)
Select Case Cat
[Code]....
View 3 Replies