Adding Up Variables Declared As Double Gives Strange Results
Sep 4, 2011
I have declared 2 variables as Double in my VB Code. Example:[code]Somerwhere down the code, after some internal calculations, the variables A1 and B1 have attained new values. Example:[code]Do I need to do a conversion of some sort in my program codes ??
View 12 Replies
ADVERTISEMENT
Dec 15, 2009
Why does: DateTime.Now.ToString("M") not return the month number? Instead it returns the full month name with the day on it. Apparently, this is because "M" is also a standard code for the MonthDayPattern. I don't want this...I want to get the month number using "M". Is there a way to turn this off?
View 6 Replies
Mar 4, 2009
I have a string with 3 rows. Each row is ended with <CR><LF>. I have verified this by writing the string to file and open it in notepad++The problem I am having is that I want to split this string into an array. When I split on vbCrLf I get 6 lines with this code:
View 2 Replies
Jan 14, 2011
I am working on which is displaying "Live" CPU stats for a remote Server.I am creating a SWbemRefresher and everything works great, for about 2 minutes. Then I start getting "Odd" results, almost like the objects in it get corrupt.Let me explain. So I create my Refresher like this and iterate through each item in the collection, writing the results to a database:[code]....
The above works fine but after I while I start seeing strange results.So I may see things like 5 processes with the same ProcessID (which is impossible, or so I beleive?).Processes with apparently the same CPU usage which I know is incorrect.I also see processes with the incorrect ProcessID, so for example I may see ProcessID 123 and Process name CALC and then all of a sudden I will get ProcessID 123 process name winlogon, so the results are out of sync with each other.Attached is an example screenshot of what I mean which only shows two processes, but it does seem the longer I run the code (so say for 5 minutes) the more processes appear like the screenshot.
My thoughts are - the objRefresher.Refresh() does not finishfinishes half way through the loop, resulting in "skewed" results. I dont konw how I can wait or check to see if the Refresh has finished?I have tried everything I can think of and it doesnt make sense to me. Maybe a fresh pair of eyes will spot an obvious mistake .The target server is a Windows 2003 x86 SP1 box, the code is running on a Windows 7 x64 box.
View 4 Replies
Aug 25, 2009
I have a PictureBox, some TextBoxes and a 'generate' button.
code:
I want to create an 'Image Generation' Program with a little help from YugiohCartMaker.net, and when i try to generate, this error appears...
Conversion from string [url] to type 'Double' is not valid.
Also a question... why does it stop with "/y" and not with "/ycmaker/createcard.php?name="?
View 2 Replies
Mar 16, 2012
I'm attempting to create a bound WPF control; when I add a local namespace to the UserControl, I get strange output from the compiler. The header of the UserControl follows, with the offending line highlighted.[code]When that line is present, the compiler generates the following in the output:[code]
View 2 Replies
Aug 20, 2010
I have a simple table in an access database that I'm using in a VS2010 project. I have a combobox control that a user can select the horse power of a motor. I then take that selected value from the control and copy it to a string variable called gstrSelectedHP. All I want to do is run a query that will pull up the full load amps of that horse power motor from the table. I have the query already, but I need to somehow put the gstrSelectedHP in the WHERE part of the query so that it only returns that value.
View 14 Replies
Dec 8, 2009
Recently started swicthing our project from 1.1 to 2.0 framework:
getting lot of errors:
Saying VBNullString is not declared
If ScanString <> vbNullString Then
Stored = ScanString
End If
[Code]....
View 1 Replies
Dec 16, 2010
I'm trying to create a generic Controller Class for generic events. But these these events still need to access their class variable. So my idea is to create the Base Controller Class with a ModelBaseclass variable as _ClassVar, which is inherited by all of the other class Controller classes will derive from. But I want the derived controller classes to override the _ClassVar with whichever one they need.
I want to do this, so the ControllerBaseClass can have all the generic functions that all the Derived Classes would use.
Model :
Public Class ModelBaseClass
Public Overridable Function Foo() As String
Return "Name"
[Code].....
View 2 Replies
Jul 15, 2011
I have a list of variables that are being created on one line.
Dim strFirstname, strMiddleName, strLastName As String
Is it possible to set the values for all of them at once? I know this doesn't work, but this is what I'm trying to do :
Dim strFirstname, strMiddleName, strLastName As String = ""
View 3 Replies
Apr 23, 2009
I have the following code and i do no know why the program tells me that the variables are not declared.
[Code]...
View 36 Replies
Sep 30, 2009
I am trying to bind a few values in xaml to variables declared in the code behind.
e.g.
vb.net
dim test as integer = 2
[code]....
View 2 Replies
Jul 29, 2010
how variables declared with protected access in a base class are used to implement inheritance.
View 1 Replies
Jun 3, 2009
In re-engineering a windows forms application, I find that a lot of code-behind in the various form classes is duplicative and I'm trying to centralize as many procedures as possible into a base class which can be inherited and used by the subclassed forms.
This process seems to be going well and is making the code in my subclasses much simpler and hopefully easier to maintain, but I'm not sure where to draw the line between leaving code in the subclasses and engineering for generic resusability and moving it to the base class.
Specifically, in some subclasses I have code which manipulates variables and objects specific to the subclass, and although I could move the code-behind into the base class, the base class code references specific objects which are needed to compile. For example, each subclass manipulates a databound datagridview and form detail controls which allows the user to select between multi-record and detailed single-record views of a datatable.
In Visual Basic 2008 do I need to declare dummy data objects in the base class so that the base class will compile? Or is there a way to indicate that the data objects will be provided by the subclass?
View 13 Replies
Mar 15, 2012
I am finding it exceptionally difficult to pass an sql query result (string) into a variable.No matter what I try, I can't seem to get anything but boolean output from my reader function.I need to obtain staff "account type" from my staff table and then define that account type in a variable.
View 1 Replies
Mar 30, 2012
This is my first attempt at writing a program that accesses a database from scratch, rather than simply modifying my company's existing programs. It's also my first time using VB.Net 2010, as our other programs are written in VB6 and VB.NET 2003. We're using SQL Server 2000 but should be upgrading to 2008 soon, if that's relevant.I can successfully connect to the database and pull data via query and assign, for instance, the results to a combobox, such as here:
[Code]...
How do I execute a query so as to assign each field of the returned row to individual variables?
View 2 Replies
Mar 11, 2009
I am writing an calculator application and i dont know what datatype to use. i mean should the variables be single, double, decimal...?
View 1 Replies
Jan 15, 2010
In my last "Question" today Re-ComboBox", I was told that I can add the actual TimeZones into the ComboBox using the following; ComboBox1.Items.AddRange(TimeZoneInfo.GetSystemTimeZones. ToArray) I was able to get the ComboBox filled with those information. However, I'm facing a problem in using those information for my "Sunrise Tme" program.
My problem is : I need to add the "Time Zone" (is declared as Double) - which I select in the ComboBox - to the Calculated Time (in GMT). I am unable to get the Value added to the GMT, ie the Value such as 2.5 or 5.5 or 6.0, because the information in the ComboBox is of several Data-type. Keyword such as "CDbl" didn't work. What mistake am I making?
[Code]...
View 6 Replies
Nov 4, 2010
I have a VB .net application which works fine on a 32 bit systems. We tried using it on a 64bit Windows 7 system but it failed. So I set up an environment in a VM (windows 7 64bit VS 2005 SP1 all updated) and started debugging there. The problem I come across is, I have a module (Public variables and function declarations from a driver provider FTDI). When a function from module is called the result is saved in a variable also from module. But the problem is the variable is not declared.
View 1 Replies
Aug 24, 2009
I am looking for a good resource on variable naming conventions to illustrate variable type and where variables are declared. So I will have public variables, Private variables, private or local variables. I also may want to declare variables with the same name in different class code (i.e. in the code behind different forms). I am assuming good coding would dicatate a prefix for declaration location.
View 4 Replies
Jul 29, 2009
I have this code to return a list of fund sources for our organization.
Dim FundSourceList As New List(Of FundSource)
Dim fs As New FundSource
If results.Count > 0 Then[code].....
The problem is that when I loop through the resulting FundSourceList all it shows is the last value. For example, if I have three fund sources (state, federal, athletic), then when I use this code to loop through all I get listed is athletic, athletic, athletic.
For Each FundSource In FundSources
Debug.Print(FundSource.FundDescription)
Next
So I change the code to this. I moved the creation of the fs variable inside the loop.
Dim results = From result In dsResult.Tables(0) Select result
Dim FundSourceList As New List(Of FundSource)
If results.Count > 0 Then[code]....
This works fine but now I'm creating a new class over and over again. It seems a little inefficient to me. Can I not create the class outside the loop and use it over and over again?
View 3 Replies
Sep 22, 2009
I'm trying to populate it with the results from a table in a dataset, something like Dim MyStringArray() as string = {Me.MyDataset.MyUsers.Rows.Tostring}. So I would end up with, StringArray() = {"Bob", "Jane", "Sally"}. I know I'm missing something very simple but I'm just not getting it.
View 5 Replies
Jun 21, 2009
My program creates a CSV file, this works fine and each line created is correct except it does not have a double quote at each end. How does one add a double quote to the beginning and end of each record without the program thinking it is a formatting function.[code] Although neither method caused an error, neither did they achieve the desired result. Is there an easy way to do this that works?
View 1 Replies
Nov 8, 2009
label1.text = "<a href='#' onclick="window.open('PageTwo.aspx','',''); return false;">Click here</a>"
Notice the 2 quotes in bold above. I need to add (return false) so the browser won't scroll to the top of the page when the text label (#) is not found.
View 1 Replies
Sep 22, 2009
I have an object that I know was originally declared was an enum, but I need tothe specificnum type. I'm aware of the GetType method and it appears to work correctly, but I can't figure out how to go from there to a direct type comparison For reference types, you can use Typeof(object1) Is Class1, but this doesn't seem to work for value types.
View 3 Replies
Jan 25, 2012
I'm not very good with web services and I'm dealing with one developed internally in Java. This web service requires a Header element named Token with a value (an encrypted string). I've been able to add this "Token" but the service doesn't accept it. This is the request xml my proxy calls generates (proxy class built with WSDL.EXE and modified to accept a SoapHeader external class I wrote to add Header to request):
<soap:Envelope> <soap:Header>
<TokenHeader soap:actor="[URL]">
<Token>[TOKEN VALUE]</Token>
</TokenHeader>
</soap:Header>
<soap:Body>
</soap:Body>
</soap:Envelope>
And this is what the web services wants (this is a xml request made by a java tyest client):
<soapenv:Envelope>
<soapenv:Header> .....
This is the code I wrote:
Imports System.Web.Services
Imports System.Web.Services.Protocols
<System.Xml.Serialization.XmlRoot(Namespace:=[WSDL NAMESPACE])> _
Public Class TokenHeader
Inherits SoapHeader
[Code] .....
View 1 Replies
Jun 12, 2011
I'm having a problem with part of my application I'm trying to get the directory entry for a computer object in AD (it could be mutiple computer objects based on whether or not the users passes a wild card for the object name). These names would be added add a child node of the parent node "Computers" in the tree view. I'm just having problems with using the search results...
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim parentCNNode As TreeNode = New TreeNode("cn")
TreeView1.Nodes.Add("Computers")
[code].....
View 3 Replies
Jul 12, 2010
I seem to be having a heck of a time trying to figure out how to add the results from a mySQL query to an array in vb.net. Right now, I only understand that you have to define the dimension of the array, however this is shy of impossible since the dimension of the array will change due to different results from the query. What is the proper way to take my results and put them in an array?
View 12 Replies
Apr 18, 2012
I'm trying to write a function which obtains the sequence_number by counting the records in a table that fit a particular criteria and if the result is 0 or nothing sets a variable to 1 but if the result is 1 for instance, the variable will be set to 1 + 1.
This is the code i'm using but i'm not getting the correct result when results are actually returned. For instance, if the result of count is 1, i want "seq" to equal 1 and total (which represents the sequence # assigned to the next record which is entered with the same plan and date) would therefore be 2 which is the result of seq + 1 (i.e. 1 + 1)
[Code]...
View 6 Replies
Nov 12, 2010
I have a string value that I get from an xml-attribute. The value (string) is 14.666666666666666. I want to convert it to a double value and then get the smallest integral value, which is 14, and then convert the result back to a string value to assign it back to the attribute value.
This is my code:
p.SetAttributeValue("MyAttribute", Math.Ceiling(CDbl(TheAttributeValueAsString.Value)).ToString)
View 8 Replies