Variable Not Working As Expected?
Jul 28, 2010
I have declared a String variable(PC) for use within another String variable(currentQuery) to form a SQL statement to pass to my SQLDataAdapter variable.
I'm performing this action to change the string variable(PC) for the different onClick events I have.
It seems i can change this variable (PC) within my onClick event handlers and the 'PC' variable will change when I apply it to a testing Text Box 'testTextBox' but not for the currentQuery variable.
Do i need to perform this action as a function or am i missing something obvious - code below - I don't want to spend time writing a function to return a string value for my SQL statement if i can just tweek something in my code (below).
Partial Public Class IVMain
Inherits System.Web.UI.Page
Dim DBConn As New SqlConnection("Data Source=hnaServer;Initial Catalog=Hnastatus;User ID=Test;Password=test")
[Code]....
View 3 Replies
ADVERTISEMENT
Apr 9, 2009
I have an Excel worksheet with a Source Cell and a Target Cell.Via GDI API functions, I draw a temporary gradient fill over the source cell which happens to be cell "D6"then, I make a transparent copy of the temp gradient fill drawn over the source cell and place the copy (ie the transparent gradient fill) over the target cell which happens to be cell "D9".
View 3 Replies
May 27, 2011
I want to fetch data from a database table modify it and update it without being dependent on the database provider and the database structure, because it will be part of a library.My first attempt was as follows:
'factory defined somewhere else as DbProviderFactory
'connection is a working DbConnection
Dim selectcmd As DbCommand = connection.CreateCommand()[code]....
it did not work. After further investigation I figured out that the Commands the CommandBuilder generated were useless, because it inserted ? instead of @param1 for all Parameters. It generated something like INSERT INTO tbl1 (field1, field2, field3) VALUES (?, ?, ?) for the InsertCommand.I would really like to use the CommandBuilder, because it is simple and I don't have something complicated like JOINS.
View 1 Replies
Apr 12, 2012
I have a query like so:
Dim clcexists = (From p In dbContext.Signatures _
Where p.StudentID = people_id _
And p.ContractType = "clc" _
Order By p.ID Descending _
Select p)
Later I check whether any rows exist in clcexists using IsNothing like so:
If IsNothing(clcexists) Then ' If no CLC is on file.
clcfirst = Date.Now.Subtract(year)
clcdate = clcfirst
[Code]....
But IsNothing() is not functioning like I expect. There is no row in the results table, but it is still acting as if there is and going to the Else clause.
View 3 Replies
May 18, 2010
I am running Windows 7 pro and using Visual Basic 2010 express.I have written a small program to switch on a USB relay which is controled by a serial port.I have debuged the program and it appears to work correctly. I have published the program and if I start it from thr run menu / desktop shortcut / or through explorer it works as expected.
However I have tried to run it by the Task Scheduler and then it fails to run as expected. I have a small section of code that checks to see if the serial port is present if not I have used messagebox.show to ask for the relay to be pluged in. In every case other than when running through the Task Scheduler the messagebox works with the Task schedulerit doesn't show the messagebox and the program hangs I have included the code I have used.
Dim retry As Boolean = False
Dim data() As Byte = {255, 1, 1}
Do Until retry
[code]....
View 2 Replies
May 22, 2011
[URL]. I have a Multi-Line textbox with several accounts in it. They are in email@email.comassword format on separate lines. All the code is right, but it goes really weird and loops like 3 times before logging in. Eventually logging into the last account on the Textbox instead of the first. It should just login to the first account...Logout....Login to the second account...Logout and continue the process.
If you want to test it, just put a web browser and a textbox1 multiline box, a button and enter a few working hotmail accounts and you'll see.
Check line 17
Looks like a lot of code, but line 17 is the only bit that needs to be looked at. The rest is just junk/non-relevant to this problem. It separates the accounts perfectly and stuff, but just wont login in the right order.
View 2 Replies
Aug 21, 2009
I have a form with a split panel. In the one split are a group of buttons which I want to programmatically change the color of the last pressed button.The following loop seems to run correctly and set the colors correctly but the form doesn't represent that. Once the loop is completed and I recheck the button colors, they revert to previous state.[code]I can get the desired effect by doing the below code but seems less elegant and would obviously require updates as buttons would be added or removed.[code]
View 2 Replies
Feb 26, 2011
Code:
'// Declaration of Variables
Dim Air_AH As Integer
Dim Air_Undercut As Integer
Dim Air_Bot As Integer
If rad_WoW_AH_Maelstrom_AH.Checked = True Then
[Code] .....
Shield is returning 0 regardless of the expected value. Can you not have three conditions in an if statement?
View 2 Replies
Apr 10, 2010
Selected Case of a Listbox isn't working as expected
View 2 Replies
Jul 14, 2011
I was toying around with some of the linq samples that come with LINQPad. In the "C# 3.0 in a Nutshell" folder, under Chater 9 - Grouping, there is a sample query called "Grouping by Multiple Keys". It contains the following query:
from n in new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }.AsQueryable()
group n by new
{
[Code].....
View 1 Replies
Aug 8, 2011
I have the following code,
PB.ForEach(Function(x) x.Cost = GetPartCost(x.PartNumber, x.Units, x.Cost, FB))
Return PB.Sum(Function(x) (x.Cost * x.Qty))
However it always returns 0. I've checked and the GetPartCost function executes and returns a non-zero number but the list item cost properties are never updated.The property is just a simple property,
Public Property Cost() As Double
Get
Return _Cost[code]....
If I set a breakpoint in the Set of the property, it never gets hit.
View 1 Replies
Sep 23, 2009
I am working a building a form that is generated using Project|Add Windows Form|Form.
In the Load procedure, I placed the following code:
dbObject.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:scdbv4datascdbdata.mdb"
rsObject.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
[Code]......
View 10 Replies
Jul 29, 2011
Full Program: Option Strict On : Option Explicit On Module Module1
[Code]...
After I ran it, I had a file a.txt in my debug folder but the size is 0 bytes (and when i open it is empty of course) Shouldn't the output had "asd" in it ?
View 2 Replies
Nov 24, 2011
I'm not sure why the following code is not working as intended:
CODE:
Where litMessage is the name of the literal control and messageBody is the name of the string variable.
My intention is to output a string onto a web page and to replace the line breaks with a br tag so that it can be displayed on the page correctly. However, nothing is replaced. When viewing the page source, it looks like the line breaks still exist in the string. Similarly, when displaying the string via MsgBox, it displays normally as well. I have also tried wrapping the output with the pre tag and it displays the line breaks properly as well.
The string was originally entered by a user through the use of an asp:Textbox and saved into a MSSQL database. It's retrieved and displayed on another webpage using an asp:Literal control. The only thing that happens to the string before it is submitted is that it is trimmed (i.e. textbox.Text.Trim()).
Perhaps there is something I did not consider?
Edit #1: Due to time constraints, I've decided to just wrap the text with the pre tag. It's an acceptable work around as it preserves the line breaks. Unfortunately, it doesn't explain why the code didn't work in the first place. In the meantime, I'll just leave the question unanswered until I find a proper answer.
Edit #2: Solution found and answered below. UpdatePanel tag added to the question for future reference.
View 5 Replies
Jan 5, 2011
Dim x = GetType(List(Of )) 'valid statement
Dim list As New List(Of String)
Now I want to see if list is a List(Of T) variable: Dim isList = TypeOf list Is List(Of ) On the last line I get a compile error: "Type Expected". Is there any cheap-performance TypeOf operator alternative for generics?
View 2 Replies
Sep 14, 2010
I have below xsl code but it is not working, could anybody please guide me.
<xsl:variable name="indent">
<xsl:if test="@type='Text'">
<xsl:if test="@required='yes'">[code]..
I need to assign return ValidateText(this( onkeypress even if inside xml the required is yes.
View 3 Replies
Jan 17, 2009
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Interval = 5000
Timer1.Enabled = True
[Code] .....
How would I take a textbox (textbox2.text) and make it show what part of the interval the timer is on? like how do I watch the timer while its counting?
View 4 Replies
Feb 3, 2010
The data:
Date
Name
Price1
[code].....
View 2 Replies
Oct 26, 2010
Does anyone know what is wrong with this IF Statement? I'm getting the errors "Expression Expected" and "End of Statement Expected".If DropDownList1.SelectedValue = "Educational Sponsoring" Or "Grants" Or "Product Training" Or "Centres of Excellence" Then
[Code]...
View 4 Replies
Mar 25, 2010
I am getting the error:"Range variable 'sender' hides a variable in an enclosing block or a range variable previously defined in the query expression."for this
Imports System.Data.SqlClient
Imports System.Linq
Public Class Form1
[code]....
I can select any other item from the table without the error. "sender" has the same properties as "receiver" in the SQL table.
View 2 Replies
Aug 23, 2011
I receive the error -
[Code]...
View 10 Replies
Apr 24, 2009
I keep getting this error in my code: " end of statement expected".[code]Please use code tags when posting your code.
View 8 Replies
Oct 12, 2011
Imports System
Imports System.IO
Imports System.Linq
[Code]....
I am setting the DataSource of the LIstView as Photos.ToArray() in the code behind..but still i get the error.. "Select DataSource for ListView"
View 1 Replies
Jan 19, 2011
I am currently working on VB. I am using Visual Studio 2008.
The piece of code below is a console application which builds without any error.
Imports System.Net
Module Module1
Public Sub Main()
[Code]....
View 1 Replies
Dec 6, 2011
Protected ButtonsClass(count).ButtonsArray = CtrlButton
Where
ButtonsClass As Class
ButtonsArray As Button
CtrlButton As Control
count As Integer
View 3 Replies
Sep 8, 2010
I have a statement 'ptr.Line((xmin, ymin) - (xmax, ymax), B)' which was originally coded in VB 6.0. Could anyone tell me why this code is now throwing an error in VB.NET?
View 6 Replies
Mar 28, 2011
why the Output window does not print the "xxxxx" part of the string? Looks like I'm missing some basic understanding about something...?
I'm sending string messages over TcpClient, and when building the strings, I don't add any special characters on the sender side, and neither on the receiver side.
[URL]
EDIT:
I'm building my strings at the sender side like this:
Private Sub SendData(ByVal stringArray As String())
SendData(GetMessageString(stringArray))
End Sub
Public Function GetMessageString(ByVal array As String()) As String
[Code]....
View 2 Replies
Jun 21, 2012
this code always return '0' i don't know why
Dim cur_month = DatePart(DateInterval.Month, Now).ToString()
Dim cur_date As String = "01/" + cur_month + "/" + (DatePart(DateInterval.Year, Now).ToString)
[Code]....
cnb_mnth is ComboBox for Month
txt_year is Text Box For Entering Year
View 1 Replies
Jan 5, 2009
For some reason when i declare an array and set it to a certain amount of elements then under it specify the elements it works in VB 2005 but when i do it in VB 2008 it get : "declaration expected " and i get words underlined.
Public Class Form1
Dim words(20) As String
words(1)="Computer"
End Class
Let me know how to do this in 2008!
View 8 Replies
Jun 30, 2010
A "declaration expected" error occurs when attempting to use any of the MY objects. What declaration needs to be made?
View 4 Replies