Why Does The Assignment Fail
Jun 5, 2012Concerning this code... Dim i1 As Integer = Nothing
[Code]...
Concerning this code... Dim i1 As Integer = Nothing
[Code]...
I have a school assignment and I just started to learn VB. Until now I/ve done pretty good however I encountered a problem which I can't solve in this assignment. So, I would ask if someone could tell me what I'm doing wrong?
This is the assignment:The application calculates the new hourly pay for each of three job codes, given the current hourly pay for each job code and the raise percentage (entered as a decimal number).
a.) before the form appears, use the InputBox function to prompt the personnel clerk to enter the raise percentage. You will use the raise percentage to calculate the new hourly pay for each job code.
[Code]...
I wan to create a program that can get the application name.i can start the program but cant get the program name[code]...
View 1 RepliesIs there a way to set a variable in VB.NET in an IF statement. I would like to do the following:
[Code]...
Is there some way I can get the last "ElseIf" to work? I know I can re-write it to get it to work but is there some syntax that will make it work the way it is?
I'm having an odd problem with an ASP.Net page.I'm getting an object not set error message when assigning a string literal to a variable. [code] And here is the code that the error is pointing to. The last line in this fragment is the line 10 the error is complaining about [code] It seems it fails on accessing any reference type, even if it is declared locally in the load function. I originally found the problem when Request. IsSecureConnection was nulling out on me. I eventually discovered I could replace it with the above code and fail in the same way. The problem does not always happen. It seems to be triggered by publishing an update from Visual Studio, or when I head home for the day and the server sits idle all night. One or two app pool recycles seems to clear it up, and the page functions correctly. I've been doing desktop development for a few years, but I'm fairly new to web development.So maybe this is something obvious I've got configured wrong. I'm currently using .Net 4 on IIS 6. That code is in a foreach over an IEnumerable(of XElement). The stack trace still points to the string assignment, but all other stack traces are spot on, so I don't think it's a bad pdb.Also, when the error occurred this time, no amount of recycling the app pool or stopping and starting it would fix the error. I finally got it working again by switching the application to a different app pool.
View 2 RepliesWhy aren't the assignment operators (+=, -=, *=, /=) overloadable in VB.NET?
View 1 RepliesIf I put:
variableName = namecombobox.selectedItem
or
Dim variablename as type = namecombobox.SelectedIndex
Visual studio gives me the error: "Option Strict disallows conversions from object to string.
I can fix this by putting:
variableName = convert.ToString(namecombobox.SelectedItem)
Are all values contained in a combobox automatically treated as a non-string even when they are string values (in this case "Male" & "Female") and what is the correct way of assigning the value selected in a combobox to a variable?
i am making a program on visual basic 2010 and part of my objective is to calculate the tax, i am trying to calculate the TAX so this is part of my code and this is the only part which gives me errors:[code]
1. Constant cannot be target of an assignment
2. value of type 'string' cannot be converted to 'System.windows.forms.Lebel'.
I have an assign ment that says: create an application to let the user enter his or her name (first and last name), then displays the Initial in Upper Case. FOr example: you enter "John Wow", then the Label will display "JW". I know that I'm supposed to use the Substring method. But to use the Substring, I have to have the exact location of the Leter that is going to be displayed in the Label.The problem is: the name that the user enters always vary. So in strnewstring.Substring(... , ...) ---> the number in the parenthesis would vary, too. Thus, I cannot put a number in there.So how can i create a code for this particular assignment.
View 4 Repliesi need to design a sudoku( 4*4 ) for my VB assignment..and i am having problem with generating random numbers for the four text boxes i have used..
View 4 RepliesWhat is the difference between this two ways of returning value in a function in VB.NET?
Using Return Statement:
Public Function Foo() As String
Return "Hello World"
End Function
Using Assignment:
Public Function Foo() As String
Foo = "Hello World"
End Function
I'm using the first one then I saw someone using the second. I wonder if there's a benefit I could get using the second.
Maybe this is a n00bish question, but I'm used to c++'s pointers and references and this is confusing me a bit. Let's say I have the following scenario in a VB.net application:
[Code]...
The situation is this: I have a collection of objects, and during execution of the program, any of them can be fetched from the collection to be used/edited by another part of the program. Now obviously if I edit the data inside the object it is allright, but what if I want to replace the object, as I did above at line 5? I would change only the local reference (y) but not the object inside the collection!
Is there a way around this? How can I take with me a "reference to the object's reference", instead of just a reference, so if I reassign it it will also reassign the one in the collection? I hope I'm making myself clear, unfortunately english is not my native language, to be clear: in c++ this would be easy using a pointer to a pointer, or passing a pointer to the object always by reference, so calling new or reassignment on it would change the original pointer itself)
i would like to hijack the assignment operator and do some customization before an instance of my class is assigned.
example:
Dim A as New MyClass
Dim B as MyClass = A
i want custom the behavior of = is that possible?
I have post several parts of my assignment. Can someone advise me on how to do a log on screen. I have a splash which is on a timer, which is supposed to go to a logon screen. I have created the database project in visual studio 2008. Database was created in ms access 2007.
View 2 RepliesI've got one for you. I am working on a program that calculates the cost of a trip given a specific price of a Workshop say "Handling Stress for $595" the length of the workshop say "3 Days" and the city the workshop is in say "Austin for $95/day" now the issue i am having is that for example my NumDays variable (the variable for the number of days of the workshop) is not taking the value. Ive ran a Watch on the variable and it stays at 0. It also displays zero. i have assigned it an integer so it should be working if I assume correctly.
[Code]...
I am fairly new to Visual Basic, but have had extensive experience with TI Basic and am 1 month into a class at my high school in Visual Basic.I recently began a blackjack application that will play as if you had actual randomized cards. I currently have 2 variables per card, one for the value (random integer 2-14), and one for the suit (random integer 1-4). I have pictures of all 52 cards with this numbering system (21.png, 22.png, etc. The compiler understands picturebox statements as
PictureBox1.Image = My.Resources._21 It seems like there would be some way to have a variable assignment, but
PictureBox1.Image = "My.Resources._" & You1Card & You1Suit isn't recognized as it is a string. Is there some way to either randomize the pictures to generate a random picture in My.Resources as opposed to integer representations of cards? Or is there some way to have the PictureBox assignment accept a variable string?
I have a VB windows Form project that connects to several DataTables in an Access DB. On my form I have several textboxes, comboboxes and datetimepickers that are bound to those sources. With one table in particular when I try to update the tableadapter after editing one of the textboxes the update method fails. No exceptions are thrown, but the update method returns a zero value and the data is not updated. The update will work when just the comboboxes or datetimepickers are edited, but as soon as a textbox is edited also, update will not work.
Other DataTables within the project are set up in the same manner but are not having update issues. I can't figure out what about this one particular table is causing an issue. Can anyone give me any thoughts on where or what to troubleshoot?
I am currently trying to write a little wrapper around post-review to automatically post however this function fails when it comes to Dim results As String = sOut.ReadToEnd() and I can;t suss out why,
Edit: It doesn't produce an error it just seems to go into ReadToEnd() never to return
Function postReview() As String
Dim psi As ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("cmd.exe")
psi.UseShellExecute = False
[code]....
Further Info: The actual command is working as I can see it posting to Review Board. But it just seems to get stuck in a loop while waiting on the Stream to complete. I have tried with Read and Readline with no luck?
I have a dropdown list that I am binding to a datatable. Here is the code I am using to do it:[code].....
Unfortunately, the line ddlBuildAddr.SelectedIndex = addressId is failing. Looking at this line through the debugger, the SelectedIndex goes to -1, while addressId goes to 2. What gives? Why would the assignment operator flatout not work?
My understanding of assert.fail was that if the line is executed, the test will fail.owever, I have found an instance where the assert.fail is executed, but the test passes.If the Assert.Fail statement is within a try block, the test will ALWAYS pass, even if the code execution executes the assert.fail. For example, the following test will always pass, even if the sub fails to throw an exception.
View 2 RepliesI'm trying to convert the following algorithm from C# to VB.NET and the VB.NET I have is not producing the same results as my C# algorithm, can someone tell me where I've gone wrong in my conversion?
public static IEnumerable<T[]> Combinations<T>(this IEnumerable<T> elements, int k)
{
List<T[]> result = new List<T[]>();
[code]....
I am working on a mdi project and I have a few different xml files that I need to read in and I would really like to use multiple datatables, but only one dataset. I have always struggled to get a datatable.readxml(filename) call to work without an invalidoperationexception b/c of the schema stuff. I don't understand it very well and in the past my workaround was just to make another dataset. I am trying to avoid doing that from now on. I have written a routine called readxml which will take a xml file name, xml schema file name, and a datatable name and return to you a populated datatable..but I can't get it to work.
Here is my call to the read xml method (comes from my main mdi form class during form load)
Dim dt As DataTable = globals.xml.readxml("SqlConnectionString.xml", "SqlConnectionString.xsd", "sqlConnection")
Here is my readxml routine, I will post two versions of what I tried attempt #1: use a string of raw xml and a xmlreader
[CODE]...
I do an dns test before i send mail to ensure i dont get errors.But there is a problem, when i try to send an email to an adress xxxxx@eco-log.sei get an error from the dns function. when i try to delete the "-" in the mail adress it works.at first i tohught it was because of the "-", but i made an email at zzzzzz@eh-design.se and it works like a charm, what could be the problem then? It is 100% sure that "xxxxx@eco-log.se" is an existing email/dns.The error message im getting is "No such known source"(freely translated)
Heres the dns check code:
Public Function testDNS(ByVal dnsstring As String) As Boolean
Dim email As String = dnsstring
Dim host As String() = email.Split("@")
Dim hostName As String = host(1)
[code]....
I have this protocol for getting a favicon: (I stole it from Thomas Maxwell, and adapted it, but still)
Public Shared Function GetFaviconSilent(ByVal IconURL As String)
On Error Resume Next
Dim oIcon As Icon
[code].....
[code]did anyone know what wrong with my code..i've fail to insert in table USERID in access..actually,i've use the same code to insert before this and it succeed..
View 19 RepliesThis assignment works for me TryCast(Me.NamingContainer, LDHello).ToggleChartConfigurationSections = AddressOf LD_SayHello whereas Dim objLDHello As LDHello = TryCast(Me.NamingContainer, LDHello) AddHandler objLDHello.LoveAndLoveOnly, AddressOf LDSayHello fails with an error message like LoveAndLoveOnly is not an event of Universal.LDHello. Visual Studio intellisense is able to pickup the event whereas the background vbc and build compiler are failing. When I need to stack multiple subscribers to the event I need to use AddHandler right?
View 6 RepliesI have a custom class that simply contains a public variable X.Let's say I have two instances of the class, A and B.If I execute an assignment operator, such as:A = B then I want A.X equal to the VALUE of B.X.But, I'm pretty sure that this will just assign B to the variable A.Assigning pointers, in C++ lingo.I looked in the VB.NET docs, which state that "The operator can be overloaded only as a relational comparison operator, not as an assignment operator."
View 7 RepliesI have a set of nine double variables declared earlier in a program (i.e., phq91 through phq99) that I have placed within an array. The variables need to hold numeric data that correspond to item responses within combo boxes.
View 6 RepliesI'm completing our assignment we are using vb.net as front end and ms access 2003 as back end but are unable to delete data in the database after clicking on delete button it shows result on front end.code for next does not work give code for next
View 2 RepliesI am having a structure that is actually a simple byte with more functionality.[code]...
If there would be a way to inherit from Structure I would simply inherit from Byte adding my functionality, basically I just need a byte Structure with custom functionality.
My question is also valid when you want to define your new singleton member value-types (like, you want to define a nibble-type for instance etc.) and you want to be able to set it with an assignment to number or other language typed representation.