Casting An Integer To A Single, Preserving Bit Representation?

Jun 24, 2011

Is there a fast way in VB.NET to take a 32-bit int and cast to a 32-bit float while preserving the underlying bit structure? BitConverter will do this, but I'd like to cast it directly without involving byte arrays.

View 1 Replies


ADVERTISEMENT

Converting String To Its Single Representation?

Feb 15, 2010

I am trying to convert a string to a single. Ive tried csng() directcast() and single.parse. The first two methods crash. Single.parse says input string was in incorrect format. The number is 777.7932 so should convert fine. Ive tried it this way:

'x = single.parse(pts(0), globalization.NumberStyles.AllowDecimalPoint)

how can i convert a string representation of a single data type that is read from a text file into its single data type. I checked control panel and globalization settings are set to english.

View 6 Replies

Handling Integer Representation Of True And False

Aug 6, 2009

While testing some code i found something strange how vb.net (2005) is handling integer representation of true and false (or yes and no). Or at least i dont understand the reason for this.Im used to C or Java where 0 is false and everything else is true. To get to the point, here is the code: [code] And the out put is:X: 1 Y: 2x is truey is truex and y is false.If x and y or both individually true, why does it return false when you evaluate x And y.However, change the values of x and y to 4 and 5 you get this:X: 4 Y: 5x is truey is truex and y is trueJust another example, which seems to work how it should to me:X: 4 Y: 0x is truey is falsex and y is false.

View 7 Replies

VS 2008 Convert Binary Representation To Integer

Apr 6, 2010

I am using this to convert a number to binary representation:

[Code]...

View 1 Replies

Casting String To Nullable Integer

Jun 28, 2010

I wonder if this is not possible dim mystring as string="1" dim myint As Nullable(Of Integer) myint=0 myint=mystring It crashes on the last line why is that? mystring is already integer (1) , i dont have to cast using cint, i thought. option strict off- if this cause the problem

View 7 Replies

[2008] Casting Double To Integer?

Feb 5, 2009

I'm trying to write a (WPF) program with Option Strict on, but I have a problem.
I have a Canvas with a background image, and I want to use the coordinates of where the canvas was clicked to determine what should happen next. (Something like this)

Dim p As Point = e.GetPosition(DirectCast(sender, Canvas))
Dim imgColorMap As System.Drawing.Bitmap = My.Resources.ColorMap
Dim c As System.Drawing.Color = imgColorMap.GetPixel(p.X, p.Y)

This gives me the error: "Option Strict disallows implicit conversion of 'Double' to 'Integer'" for p.X and p.Y I have tried several things, like Math.Round but strangely enough that also returns a double.

How do I cast/round these Double values to Integer, so I can use them in my GetPixel method?

View 3 Replies

Reverse Casting - Single Back To Double?

Nov 10, 2011

I wanted to know if it's possible - after casting a double to a single, to turn it back into a double again? i tried doing something like:

Dim x_double as double = 12345678.987654321d
Dim x_single as single=x_double
x_doubble=Cdbl(x_single)

but it doesn't give me the original value.

View 2 Replies

Reverse Casting \ Single Back To Double?

Mar 30, 2010

Reverse casting? Single back to Double

View 5 Replies

Casting A Boolean To An Integer Returns -1 For True?

Sep 1, 2010

I am working with some VB.Net code that seems to be casting a boolean value to an integer using CInt(myBoolean). The odd thing that is happening is that it returns -1 if the value is true. For example:

CInt(True) // returns -1
CInt(False) // returns 0

Is this common in other languages? I thought that a boolean would be 1 if true and 0 if false. Also, is there a way to make VB assign 1 to true instead of assigning -1?

View 5 Replies

PerformanceCounter.NextValue Is Integer Not Single?

Oct 15, 2010

PerformanceCounter.NextValue appears to return integer values instead of single values.The code below has a button, Button1 and a textbox, TextBox1. Click on the button and the textbox is filled with the CPU usage of each process at a given time. I would assume that these values should match with the values in task manager.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = Now.ToString & vbCrLf & vbCrLf
TextBox1.Text &= GetInfo()
Application.DoEvents()

[code]....

My guess is that these processes are taking up SOME amount of CPU and are just being rounded down to 0. In the first example I would guess that the CPU amount is rounded up to 100 %.

View 1 Replies

Basic Array Construction - One Column Or Entry Would Be A Single Integer

Oct 27, 2009

How you might construct an array like the following: one column or entry would be a single integer, like 0, 1, 2, 3, 4... - i need this as an index of each one's position in the list the second would be 0 or 1, or true or false the third would itself be a list of integers 0,4,5,2,7,2,5,2...

So all together one entry would be {0; 0; 0,4,5,2,7,2,5,2} while the next might be {1; 0; 6,8,2,5,2,3}

I'm having a terrible time wrapping my head around this. It's mostly the third column which is actually a list in itself, that is giving me trouble

View 13 Replies

Preserving Variables Through Postback?

Mar 7, 2011

I'm creating a Website and I noticed that when the page reloads due to a postback, My variables all are unloaded so I have a Null variable,

For Example I'd Declare a String With an initial value of "" then later in the code set it to "Some Value", when a button is clicked to cause a postback, this value then becomes "" again

Is there some way to preserve variable so their values remain the same after a postback

View 4 Replies

Asp.net - Preserving Dynamic UserControl On PostBack?

Feb 5, 2012

I'm dynamically loading User Controls into a div, which I need to preserve on postback in order to call a Save method once the user is done editing them. The div and all the User Controls have the EnableViewState = True.

ASPX Div Declaration

<div id="dynamicDiv" runat="server" enableviewstate="true">
</div>[code]......

So... the controls load fine, but I can't find a way to preserver them on postback, I can't reload them because the user has already input data into the usercontrol (which is what I need to save).

P.S. I tried adding them to a list and then adding the list to the ViewState, but I haven't been able to properly serialize the control. I implemented ISerializable for the userControl's code behind but then it says the ASCX is mot marked as serializable with

Type 'ASP.controls_userControlType_ascx' in Assembly 'App_Web_pn5vxhpw, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

View 2 Replies

ITextSharp HTML To PDF Preserving Spaces

Sep 30, 2011

I am using the FreeTextBox.dll to get user input, and storing that information in HTML format in the database.A samle of the user's input is the below: [code] I want the HTMLWorker to perserve the white spaces the users enters, but it strips it out.Is there a way to perserve the user's white space? Below is an example of how I am creating my PDF document. [code]

View 3 Replies

Preserving Variables To Use On Multiple Forms?

Sep 25, 2010

I am trying to have it so that when a user hits a button to enter a shop, it will open a popup window which will have the shop's goods. The only problem is I can't figure out how to keep the variables working between the two windows.

I need to get the variable 'gold' to transfer to and from form2(the shop window) and whatever is bought at the store to transfer back to the main window.

Right now, when I go to form2 all the values are 0, and all the variables I used on form1 are undeclared on form2.

How do I access variables from form1 to show up in form2? Is there an easier way to accomplish this than using a separate form?

View 3 Replies

Hide PictureBox Image While Preserving Imagelocation?

Oct 19, 2009

I'd like to hide the contents of a picturebox while still preserving it's imagelocation, width, height, borderstyle, top, left, and sizemod properties. Is this possible?

View 2 Replies

Preserving NULL Values In A Double Variable?

Apr 15, 2010

I'm working on a vb.net application which imports from an Excel spreadsheet.

If rdr.HasRows Then
Do While rdr.Read()
If rdr.GetValue(0).Equals(System.DBNull.Value) Then

[Code]....

But when passing the value to the SQL insert I get: "Nullable object must have a value."

Solution:

Fixed by changing the datatype of the parameter in the sub I was calling and then using Variable.HasValue to do the conditional DBNull insert.

View 3 Replies

Sort A Structure With Preserving The Position Of Similar Numbers?

Oct 28, 2010

I am using structures in my programming and I sort the structure according to a value in the structure using IComparer.This is a simple example for what I want.

Dim MyArray(6) As Integer
MyArray(0) = 1
MyArray(1) = 45

[code]....

How does number 1 get sorted? Is it brings the newest 1 to top or keeps the old 1in the same index? In my original example (before sorting), MyArray(0) = 1 and after sorting MyArray(0) = 1.Is this the same original 1 or this another 1 (the newest one added to the array) moved to that position?In case the MyArray(0) = 1 after sorting should be MyArray(5) = 1 before sorting.

Here is my a sample of my Code:

Public Structure ToSolve
Dim Con(,) As Integer
Dim Discharge(,) As Double

[code]....

Using all these methods, how can I preserve the positions of similar number in the list? i.e. I want to bring the newest 'Similar' value to the top of the list.

View 1 Replies

Throw An Existing Exception While Preserving Its Stack Trace In VB?

Nov 18, 2011

If I have an existing exception object (I'm not in a catch block, I just happen to have been given an exception object), is there any way (re)throw it while preserving it's stack trace?

The context for asking is that I'm writing a RunWorkerCompleted handler. If an error happened while running the background task, then this will have shown up in the Error property of the RunWorkerCompletedEventArgs. To keep the code simple I want to use the same error handling code to trap this, or any error that happens later during the handler. That means I need code like this:

Private Sub OnDone(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)

[Code]...

I don't think that using an InnerException here (ie. saying something like Throw new Exception(ex)) will work because then I have the problem that my Catch block has no way of knowing whether the exception it's supposed to be handling is the outer one or an inner one. StackOverflow seems to have various similar questions, but I've not found anything that describes this particular situation.

View 1 Replies

An Object Representation Of System ?

Nov 6, 2009

is there an object representation of System that i can Extend upon such that the extended method becomes global.

<Runtime.CompilerServices.Extension()> Public sub globalprocedure(ByVal asystem As ?)

View 3 Replies

C# - Stackoverflow .net Language Representation?

Jun 27, 2012

[URL]notice that the tag topic count for C# is in excess of 8900 while the vb.net tag topic count is sitting at 1019. Does this mean that there is a shift towards c# as a .net language of choice. the only reason I decided to build some applications for work using c# was that I like curly braces - after all vb has the same language support as c#, doesn't it so there should be no advantage to choosing one over the other; other than curly braces;)

View 7 Replies

Enums - .NET Enumeration Representation?

Apr 16, 2010

Is it guaranteed that the numeric values for an Enum with only uninitialized values start at zero and increment by one in the order defined?

View 2 Replies

Graphical Representation Of Data?

Aug 15, 2009

I am totally new to the graphical representation of the data. I want to make a progress report of students, based on marks achieved each year.For example, in year 2005 marks were 750. in 2006 780 in 2007 800

View 15 Replies

Office Automation :: Copy Worksheet To Another While Preserving The Original Format

Dec 8, 2009

I am using Visual Studio Professional 2008. I am writing a program in Visual Basic 2008 that copies the Used Range from one worksheet to another worksheet, I am able to achieve this by the following code segment:

[Code]...

View 5 Replies

Decoding File To Graphical Representation?

Aug 2, 2011

I have a file from the client which is a text file. I have to decode the file to a graphical representation. Is there any way I can do it?

View 16 Replies

Graphical Representation Of Array Sorting ?

Dec 30, 2009

I want program to do Graphical Representation of array Sorting in vb.net with bars/shapes.

View 1 Replies

Determine Local Representation Of A Specific GMT Datetime?

Nov 12, 2010

I want to get the date value for

Nov 1, 2010 00:00:00 GMT

expressed in my local time.What is the best way? Currently, I am doing this:

Dim NovGmt As Date = New Date(2010, 11, 1, 0, 0, 0)
Dim Nov1AsLocal As Date = GetGmtExpressedAsLocal(NovGmt)
Private Function GetGmtExpressedAsLocal(ByVal gmtDate As Date) As Date

[code].....

tell me difference between the Date and DateTime datatypes? Is DateTime newer than Date or is it just a synonym for Date? If the latter, why have both?

View 1 Replies

Hashtable - Get String Representation Of Object Reference

Jun 3, 2011

I want to make a hashtable of object references and I want a different object's reference to be the key. How can I do this in vb.net? In java (assuming I am using the default toString method and that add() takes a string as a key and an object ref as the value) this would be something like: hashtable.add(obj1.toString(), obj2)

I do not want to use a vb.net gethashcode() function because I want deep clones of objects to have different identifiers. A related question is what is the default toString in vb.net? How can I get a string that represents an object reference in vb.net?

View 3 Replies

Multiplying The String Representation Of REAL Numbers?

Jan 12, 2012

<edit> Now showing the difference as a DECIMAL. Result looks like zero every time. </edit>Disclaimer: This code is provided "as-is" and should be treated as Freeware.( However any donations would be welcome as I have a "so-so" part-time job ).Please note all real numbers to be used should be in this format
"0.000000000000"Do not use numbers in string format in scientific notation like "1.2345E -06"I was feeling bored and decided to add to the code from JohnWein in this thread where I have used a routine that will multiply the contents of two long strings together.>>[url]I have now added a bit of code so you can multiply two really long numbers with or without a decimal point as a full-stop ( period or dot, call it what you like ).

[code]...

View 5 Replies

VB 2008 Replacing Characters With No Visual Representation?

Jun 22, 2012

my OCR copy text to a TextBox with “” at end, “” acts like enter key. Is it possible to replace it to something or remove it? For example, I want to copy number “1000” to my text box with OCR but I get “1000”(it’s a little different boxes, I couldn’t copy exact ones here). And I can’t do

TextBox2.Text = TextBox2.Text.Replace("", "")
, because  is an "enter key" and what I get looks like that:

View 10 Replies







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