Hello Forum,
I'm trying to convert a string of Hex, from a serial input, to it's decimal Float value then to String for a Textbox and Listview.
I get it to Float - the debug window displays the correct value, but it seems that it's not really a number because I can't do anything with it after that.
Here's the code:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I've tried each of these lines one at a time and in combinations. Always I get a NumberFormatException error. I can't avoid the Hex String input, I have to deal with it. I'm open to suggestions on how to get it into a format that will display on the screen as a real (decimal) number.
I'm testing on an Android 2.2.2 device. I dunno if that's too old.
Any thoughts on what I'm doing wrong?
Ta, Michael.
			
			I'm trying to convert a string of Hex, from a serial input, to it's decimal Float value then to String for a Textbox and Listview.
I get it to Float - the debug window displays the correct value, but it seems that it's not really a number because I can't do anything with it after that.
Here's the code:
			
				B4X:
			
		
		
		Dim sRx As String
Dim fRx As Float
Dim dRx As Double
    sRx = "43030FF4"    'Hex string = 131.06232
    fRx = Conv.FloatsFromBytes(Conv.HexToBytes(sRx))'correctly converts String to Float
    Dim dRx As Double = fRx    'Float is correct, but this assignment don't work
    fRx = fRx * 10            'This don't work - NumberFormatException
    txtResult.Text = fRx    'This don't work.
    sRx = NumberFormat(fRx,0,2)    'This don't work - NumberFormatException
    ListView1.AddSingleLine("PVar: " & sRx)    'This is what it's all forI've tried each of these lines one at a time and in combinations. Always I get a NumberFormatException error. I can't avoid the Hex String input, I have to deal with it. I'm open to suggestions on how to get it into a format that will display on the screen as a real (decimal) number.
I'm testing on an Android 2.2.2 device. I dunno if that's too old.
Any thoughts on what I'm doing wrong?
Ta, Michael.
 
				 
 
		 
	 
 
		 
 
		