We help IT Professionals succeed at work.
Get Started

How to write values correctly in a file.

cmdolcet
cmdolcet asked
on
424 Views
Last Modified: 2012-05-10
When I look in my export File I see that my saved values are 7 and not 7.000 the way I typed them into my textbox. What do i need to do so that my values look like 7.000 I thought that declaring the variable as double would allow this to happen.
Imports System.Xml

Public Class Data

  
    'File Data Information
    Public FeatureName As String
    Public FeatureType As String
    Public FeatureComment As String
    Public D As Double
    Public X As Double
    Public Y As Double
    Public Z As Double
    Public USL As Double
    Public LSL As Double
    Public InactivePoint As Boolean
  
    Public Sub WriteXML(ByVal writer As XmlTextWriter)
        'write the top-level tag
        writer.WriteStartElement("Gage")
        'write the details
        writer.WriteElementString("Feature Name", FeatureName)
        writer.WriteElementString("Feature Type", FeatureType)
        writer.WriteElementString("Feature Comment", FeatureComment)
        writer.WriteElementString("D", D)
        writer.WriteElementString("X", X)
        writer.WriteElementString("Y", Y)
        writer.WriteElementString("Z", Z)
        writer.WriteElementString("USL", USL)
        writer.WriteElementString("LSL", LSL)
        writer.WriteElementString("Included Point", InactivePoint)
        'close top-level tag
        writer.WriteEndElement()

    End Sub

    Public Sub ReadXML(ByVal reader As XmlTextReader)
        'loop
        Do While True
            'read
            If reader.Read = False Then
                Exit Do
            End If

            'what node type do we have
            Select Case reader.NodeType
                Case XmlNodeType.Element

                    Select Case reader.Name
                        Case "FeatureName"
                            reader.Read()
                            Me.FeatureName = reader.Value
                        Case "FeatureType"
                            reader.Read()
                            Me.FeatureType = reader.Value
                        Case "FeatureComment"
                            reader.Read()
                            Me.FeatureComment = reader.Value
                        Case "D"
                            reader.Read()
                            Me.D = reader.Value
                        Case "X"
                            reader.Read()
                            Me.X = reader.Value
                        Case "Y"
                            reader.Read()
                            Me.Y = reader.Value
                        Case "Z"
                            reader.Read()
                            Me.Z = reader.Value
                        Case "USL"
                            reader.Read()
                            Me.USL = reader.Value
                        Case "LSL"
                            reader.Read()
                            Me.LSL = reader.Value
                        Case "Inactive Point"
                            reader.Read()
                            Me.InactivePoint = reader.Value
                    End Select

                Case XmlNodeType.EndElement
                    'have we reached the end of the element
                    If reader.Name = "Data" Then
                        Return
                    End If
            End Select
        Loop
    End Sub
End Class

Open in new window

Example-Export.txt
Comment
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 31 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE