VS 2008 - Assigning Decimal Type Value To Variable?

Sep 8, 2010

I want to assign a Value to a Variable of Decimal Type to do a calculation, but when I enter the decimal value (a 28 digits to the right of the decimal point - very long numbers) it gets altered. I give below what I was doing:
Dim MyNumber As Decimal = 0.7777777777777777777777777774

But as soon as I finish typing the number, it becomes 0.77777777777777779 and appears as,
Dim MyNumber As Decimal = 0.77777777777777779

And, when the cursor is kept over the altered number it shows as "Double, Represents a Double - precision floating-point number." How can I get the value I wanted to stay without getting changed? I was able to get this long Decimal value as the result of a calculation and get that appears in a text box in the same program. Is there anything I should change in the "Visual Studio 2008" to get this ?

View 5 Replies


ADVERTISEMENT

Data Type Variable - Restricting Number Of Places After Decimal

Aug 5, 2009

Any way (outside of writing rounding routines) to restrict the number of places after the decimal in a Decimal data-type variable?

View 3 Replies

VS 2008 DataRow Not Assigning To Variable?

Apr 5, 2010

I am trying to save a row to a variable so that I can remove it from the DataTable and then add it at a different index. thing is, the row that is added is empty of the information from the data row. I'm thinking the DataRow is not saving to the variable properly. Here's my

Dim row As DataRow = dtFolderList.Rows(MoveIndex)

I'm 99.99% positive I found out how to do this like last week or soemthing but can't for the life of me remember where I found it or how to do it.

View 4 Replies

VS 2008 DataSet - Assigning Value To Variable?

Dec 9, 2009

Once I have filled a dataset is there a set of properties or in-line functions that will allow me to pull the data out of said dataset without having to populate a datagrid?
Code example:
Connection.Open()
accCommand.CommandText = "SELECT CustID FROM Rental WHERE DvdID = " & DvdID
accCommand.Connection = Connection
dvdDataAdapter.SelectCommand = accCommand
accCommand.ExecuteNonQuery()
dvdDataAdapter.Fill(dvdDataSet, "CustID")
Connection.Close()
I know the information returned from the query is a single value located at (0, 0) I just can't get to it so I can assign the value to the variable.

View 6 Replies

VS 2008 Assigning Form Pointer To Variable?

Aug 31, 2010

What I want to do is either trivial, or likely impossible in the .NET framework.

I have a number of forms, with various pictureboxes, labels, etc. in each. Same names for the same items on each form. Only one form is visible at a time. What I need is some way to assign to a variable in the code which form is currently in use, such that I can reference the control on that form in a single statement.

That is, I have set up (already) references to the individual forms (call them frmForm1, frmForm2, etc.). So I can write to a textbox as:

frmForm1.textbox1.text="Hi there."
frmForm2.textbox1.text="Hello world."

What I need to be able to do is something like:

currentform = frmForm2
currentform.textbox1.text="Display on visible box"

Is such a thing even possible? Obviously, the way .Net normally wants to work is to verify everything at compile, and there is (of course) no way for it to know if whatever "currentform" points to even has a "textbox1" control.

save me a LOT of long-winded IF-THEN-ELSE to see which form is currently displayed for each and every time I want to display something. [FWIW, I *could* right everything out to every form, but I feel that would waste to much CPU time.]

View 6 Replies

VS 2008 Store A Whole Number Into Decimal Data Type?

Nov 15, 2011

my application has a data table, one of the column set as decimal type to store number, data is read from a text file and store into the data table, then display in a datagridview, I found when that number is only 1 digit, that cell displays nothing (I think no number is being store in that cell), if I type a 1 digit number into that cell is fine. for example,

1.1 [ok]
12 [ok]
0.15 [ok]
4 [not display]
9 [not display]
-23.8 [ok]

so which data type I should use on this column, in order to display all this possible numbers

View 5 Replies

Decimal Variable With 40 Decimal Places?

Apr 23, 2010

Is there a way in VB .NET to have a decimal variable with 40 decimal places?

View 3 Replies

Cast Array In Object Variable To Type In System.Type Variable?

Apr 14, 2010

I have this function:

Public Sub DoStuff(ByVal type as System.Type, ByVal value as Object)
End Sub

The 'value' argument is always an array of the same type as 'type'. How can I loop through the values of the array?

I'd like to be able to do something like this:

DoStuff(GetType(Integer), New Integer(){1,2,3})
Public Sub DoStuff(ByVal type as System.Type, ByVal value as Object)
//Strongly types arr as Integer()

[Code].....

View 3 Replies

Assigning A Variable A New Value?

Mar 2, 2010

'm trying to store a new value within a variable and then compare it to the previous value of that variable using the Math.Min method. I have created two seperate variable 1 for the previous and one for the new but I can't seem to store it

View 1 Replies

Assigning Value To String Variable

Feb 10, 2011

Using VB.6, I am trying to assigning a value to a string variable but it causes an error. I am doing that in following way:

Dim a As Variant

a = "<div style="width: 400px;"><img title=""

View 5 Replies

Conversion From Type 'DBNull' To Type 'Decimal' Is Not Valid When Field Has Data?

Feb 7, 2012

I am pulling data from a local MSSQL database using a stored procedure, then send the data to a web service. Every part of the component works well except for a pesky problem will a DBNull being returned from the DataRow field, when I know that the field is not null and has valid data. The database and associated INSERT statements that add to this field are designed to not allow NULL entries. When I debug break the program on or right before the line that throws the error I see that the field has valid data for the current row.If I add a null check to the code (as below) the operation continues as normal:

Dim dataResultsTable = Me.myViewTableAdapter.GetData(int)
For Each myDataRow In dataResultsTable.Rows
If worker.CancellationPending Then

[code]....

Why is the read operation returning DBNull instead of the data in the database?

EDIT: Just to be clear, the operation does return the proper data, but the data is not being saved into the variable.

View 2 Replies

The Null Value Cannot Be Assigned To A Member With Type System.Decimal Which Is A Non-nullable Value Type?

Sep 15, 2010

I have a Job Register Table and that table doesn't have any records.

This is my LINQ code:
Dim QRecordCount = (From LC In CntxtJobDetails.JobRegistrations _
Where LC.JobCode <> 0 _

[code].....

View 1 Replies

Assigning A Variable To A Class Then Storing?

Sep 30, 2009

i'm working on a code that i want to start creating new classes with but i want to know if there's a more direct way to send the variables used in the form to a new class for storage.

for example i've got this on a form...

Dim ClassID As String
Dim ClassName As String
Dim Grade As String

[Code]....

you know? so what would be my most direct route to get this? how should i start?

View 15 Replies

Assigning Binary Constant To Variable?

Mar 18, 2009

Any way to assign a binary value to a vb variable? All of the obvious choices don't work. I've tried prefixing with &B, appending with b but nothing seems to work.For clarification, what I was looking for (which does not appear to be possible) was how to assign a literal binary number to a variable, in a similar manner in which you can assign a hex or octal number. I was just looking for a more visually engaging way to assign values to a flag enum.

Dim num as Integer = &H100ABC 'Hex'
Dim num2 as Integer = &O123765 'Octal'
Dim myFantasy as Integer = &B1000 'What I would like to be able to do'
Dim myReality as Integer = 2 ^ 3 'What I ended up doing'

View 5 Replies

Assigning Gridview Check Box To A Variable?

Aug 7, 2011

This line of code references a checkbox in a Gridview, how can I assign the value of the check box 1 or -1, I think it is for checked or unchecked, to a variable so that I can run an if statement against it, and change it to True or False?

dt.Rows(row.DataItemIndex)("DisplayString") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked

View 2 Replies

Assigning Null Value To String Variable

Jul 4, 2010

How can I assign a variable which may contain a null value to a variable which is declared as Dim var1 as String and then use that variable to insert into access database table?

View 3 Replies

Assigning The Value Of A Label To A Variable Byref?

Sep 8, 2010

I would like a label to always show the current value of a boolean. This will change a lot of times and would like the label to ALWAYS reflect this.

Is there some kind of way to have the label set to the boolean byref (so its always the same). Currently I'm assigning the label.text = boolean onLoad, so if the boolean changes after that its not reflected.

View 6 Replies

Assigning Variable To A Label In Global?

May 11, 2011

I'm working on my final for VB.NET, and maybe it's just late...but here's how it goes. I need to make a variable named intMoney and it will be used to keep track of how much money you have and the value will be displayed in a label. Since this 'game' will have a lot of things going on, it needs to be available in a lot of places, not just one click event.

But I need to set intMoney to a starting value of 200 and then assign intMoney to a label called lblMoney. I can't assign intMoney to lblMoney in global. I get build errors. Where should I put the lblMoney.Text = intMoney?

View 8 Replies

VS 2005 : Assigning Date To Variable?

Feb 11, 2011

I have the following function that checks if a date is on a holiday or weekend and returns the first non-holiday or weekend date.

vb.net
Private Function CheckDate(ByVal D As Date) As Date
TempDate = D

[code]....

The function does return a date. But when I try to assign it to variable, it assigns a time instead. Both tempdate and newdate are declared as date also.

vb.net
TempDate = CheckDate(NewDate).Date

View 8 Replies

Assigning Objects Of Different Type?

Jul 27, 2010

I am new to VB.Net and I'm a little confused why this line happened to be valid in VB:

DataGridView1.DataSource = ds.Tables("Customerslist")

DataSource is of type Object while Tables("Customerslist") is of type DataTable. How will I know what types of objects can be assigned to the Datasource property?

View 2 Replies

Assigning A Database Field To A Run Time Variable?

Feb 8, 2011

I just started using VS2010. I am very familiar with Visual Basic 6 and was very comfortable with it.I was able to take a variable and assign a database field to iwithout using data binding. I can't seem to figure out how to do thatin VS2010 What I am trying to do is have the use enter a password to gain access to the program. The password is stored in a database so that the user/owner can change this password to suit their preference.

View 1 Replies

Assigning Variable If Value Is Equal To This / That (Select Case)

Mar 19, 2012

I have 10 checkboxes on my screen. I have a variable setup called "case" as a string. I want to know how I can say:
If checkbox1 is checked then case would be equal to "this".
If checkbox2 is checked then case would = "that"
Example of something I tried to cook up but didn't work because it tells me that I can't only use this in a "select case".

Dim Case as string
If checkbox1.checked = true
case = test1
end if
If checkbox2.checked = true
[Code] ......

View 5 Replies

Execute A LINQ Statement Without Assigning It To A Variable?

Apr 15, 2011

I have the following function

Public Function GetPositionBySchoolID(ByVal SchoolID As Integer) As CPAPositionsDataTable
Dim positions As New CPAPositionsDataTable

[Code]....

And I was wondering if there is any way to cut out assigning the LINQ result to tmp and just work with the result directly, i.e.

Public Function GetPositionBySchoolID(ByVal SchoolID As Integer) As CPAPositionsDataTable
Dim positions As New CPAPositionsDataTable

[Code].....

View 2 Replies

SELECT From An SQLite Database And Assigning It To A Variable

Dec 21, 2009

I am trying to retrieve a password from an SQLite database. The id of the row the password is in is 1. I want to assignt his password to a variable called actualpass.[code]

View 1 Replies

Asp.net - Taking A NULL Value From The Database And Assigning To A Date Variable

Mar 11, 2009

A stored procedure returns data about a user record including a nullable datetime column for their last login date. Which one is the better choice in dealing with the possibility for NULL values when trying to assign a .Net date variable?

Try
_LastLogin = CDate(DT.Rows(0)("LastLogin"))
Catch ex As InvalidCastException

[Code]....

Which is the preferred method of handling possible NULL values from the database? Is there a better way than the three listed?

Edit #2: I have noticed that the TryParse method does not play nice when trying to assign to a Nullable type.

View 5 Replies

Assigning A File Path Using Text From Different Controls To A Variable?

Aug 10, 2009

I would like to create a filepath and assign it to a string (so that it can have yet more added to it later on in my program) the code takes (well i want it to but it doesn't) the name of a drive selected previously and then adds this to a string to create a string variable that refers to a file. and then (as usual) i want to use thes files and display them in a combobox but i want to only select files that have a pre selected 2characters at the front. I have got this code so far:

' search for filer drive NETAPP-1
For i = 0 To frmDatabase.drvDB.Items.Count - 1
If InStr(frmDatabase.drvDB.SelectedText(), "\Netapp-1malika", CompareMethod.Text) Then

[code].....

View 6 Replies

Error In Assigning Object Of Nullable Type?

Jul 9, 2010

I have a structure that contains another structure. The inner structure is nullable. Now wht I do is something like the following. I create a new instance of the inner structure, set the member variables and assign the whole structure to the inner structure of the parent. But it is giving an error. The assignment is not successful. If I try to peek into the structure in the watch window, it says "property evaluation failed" for the HasValue and Value properties.

Dim testData As List(Of TestData) = Nothing
Dim testData_List1 As New TestData
With testData_List1.commonTestParam

[Code].....

View 1 Replies

Assigning The Collection Returned By Computer.FileSystem.GetFiles To A Variable?

Sep 14, 2010

Do you know how to declare a variable that can hold the result of a call to GetFiles?

I don't know how to do this, so I am using the following verbose/duplicative version:
Dim l_v_String_FoundFile As String
If My.Computer.FileSystem.GetFiles("A:u_Au_W", FileIO.SearchOption.SearchAllSubDirectories,

[code].....

View 5 Replies

Assigning The Collection Returned By My.Computer.FileSystem.GetFiles To A Variable

Mar 10, 2012

Do you know how to declare a variable that can hold the result of a call to GetFiles?

I don't know how to do this, so I am using the following verbose/duplicative version:

Dim l_v_String_FoundFile As String
If My.Computer.FileSystem.GetFiles("A:u_Au_W", FileIO.SearchOption.SearchAllSubDirectories, l_v_String_FileMask).Count = 1 Then

[Code].....

View 14 Replies

Datagridview/Query - Finding Highest Number And Assigning It To A Variable?

Jan 9, 2010

I don't know if I worded this properly, but I have a mdb query that I display in a Datagrid on my form. The first column is TransactionNumber, which is the primary key and a running total (ex. RackingTransactionKey=RackingTransactionKey + 1). What I need to do is when the form is opened, find the highest (last) TransactionNumber from the query or Datagrid and assign it to a variable (RackingTransactionKey), so I can can update it (+1), therefore generating a unique number so I can add data to the query.

[Code]...

View 13 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved