Visual Basic - ayuda con super conversor

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

ayuda con super conversor

Publicado por dna (1 intervención) el 25/10/2015 18:24:32
hola a todos ¡
no an tenido alguna vez la necesidad de convertir muchos floats a hexadecimales ?
googleas pero te encuentras con una calculadora u.u
yo trato de buscarle una solución siendo alguien que no sabe nada
lo que quiero hacer es que pueda abrir un .txt con los floats o hexadecimales y que al precionar un boton los convierta de HEX-FLOAT o FLOAT-HEX
utilice esto para abrir el archivo :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Private Sub Button1_Click(ByVal sender As System.Object, _
   ByVal e As System.EventArgs) Handles Button1.Click
   ' Displays an OpenFileDialog so the user can select a Cursor.
   Dim openFileDialog1 As New OpenFileDialog()
   openFileDialog1.Filter = "Cursor Files|*.cur"
   openFileDialog1.Title = "Select a Cursor File"
 
   ' Show the Dialog.
   ' If the user clicked OK in the dialog and 
   ' a .CUR file was selected, open it.
   If openFileDialog1.ShowDialog() = DialogResult.OK Then
     ' Assign the cursor in the Stream to the Form's Cursor property.
     Me.Cursor = New Cursor(openFileDialog1.OpenFile())
   End If
End Sub
pero no se como modificar para que habrá .txt y no como me sale (cursor files)
para que convierta de float-hex tengo este codigo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Function Sng2Hex(f As Single) As String
    ' Returns the conversion of float f to a hex string
 
    ' Worksheet function or VBA
 
    Const sPad  As String = "0"
    Dim uf      As uFlt
    Dim ub      As uab4
    Dim i       As Long
 
    uf.f = f
    LSet ub = uf
 
    For i = 0 To 3
        Sng2Hex = Right(sPad & Hex(ub.ab(i)), 2) & " " & Sng2Hex
    Next i
 
    Sng2Hex = Left(Sng2Hex, Len(Sng2Hex) - 1)
End Function
 
 
y de hex-float
Function Hex2Sng(ByVal s As String) As Single
    ' Converts hex string s to a Single
 
    ' Worksheet function or VBA
 
    Const sPad  As String = "00000000"
    Dim i       As Long
    Dim ub      As uab4
    Dim ab(0 To 3) As Byte
 
    s = Replace(s, " ", "")
    If Len(s) > 8 Then Exit Function
    If Len(s) < 8 Then s = Right(sPad & s, 8)
 
    For i = 0 To 3
        ab(i) = CByte("&H" & Mid(s, 2 * i + 1, 2))
    Next i
 
    Hex2Sng = Byte2Sng(ab)
End Function

y está es mi duda
como hago para que el archivo previamente abierto lo modifique y mas importante aun
que pueda guardarse
gracias por su atención
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder