I'm fairly new to coding VB 2008

I need help converting a text document with a type of code in it. One line looks like this: 52.000000, 400.000000, 1.3107711, 0

I need to convert that to an xml file that looks like this:
- <CuePoint>
<Time>11619</Time>
<Type>event</Type>
<Name>Marker 01</Name>
- <Parameters>
- <Parameter>
<Name />
<Value>0</Value>
</Parameter>
</Parameters>
</CuePoint>

The time in the text is 1.310771
value in text is 52.000000

I have hundreds of lines like that that need converting so I need something that will make the process automated.

I looked at other posts and was unable to convert the the code to what I needed it to do because of my lack of coding knowledge. Please help.

Did you copy and paste your XML example from internet explorer? IE adds those leading dashes to XML nodes -- but parses don't recognize them.

I tried with both firefox and internet explorer they both add the leading dash. I see that wordpad doesn't add the dashes.

Well I don't see how the lines relate to the XML sample you posted. None of the values match up. Is this intended or are they different examples? If it wasn't intended then post a matching example and we'll go from there.

this was intended. The xml value 0 is equivalent to the text value 52.000000, xml value 1 is text value 152.000000, xml value 2 is text value 271.000000. also the time in the xml is (example) 1634 which is equivalent to 1.634 seconds and in the text is has 6 decimal places. There are only three values and then time is really specific in this case.

Edited 7 Years Ago by ktkevin1222: n/a

I still don't understand your formatting but you can format it however you want:

Imports System.IO
Imports System.Text

Public Class frmReadFile
	Private Shared Sub CreateSampleFile()
		Dim sb As New StringBuilder()
		sb.AppendLine("52.000000, 400.000000, 1.3107711, 0")
		sb.AppendLine("51.000000, 401.000000, 2.3107711, 0")
		sb.AppendLine("55.000000, 402.000000, 3.3107711, 0")
		Dim buffer() As Byte = ASCIIEncoding.UTF8.GetBytes(sb.ToString())
		Dim fs As New FileStream("C:\testData.txt", FileMode.Create)
		fs.Write(buffer, 0, buffer.Length)
		fs.Close()
		fs.Dispose()
	End Sub


	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		CreateSampleFile()

		Dim sr As New StreamReader("C:\testData.txt")

		Dim sb As New StringBuilder()

		Do While sr.Peek() >= 0
			Dim line As String = sr.ReadLine()
			Dim fields() As String = line.Split(New [Char]() {","c}, System.StringSplitOptions.None)

			sb.AppendLine("<CuePoint>")
			sb.AppendLine("	<Time>" & fields(0) & "</Time>")
			sb.AppendLine("	<Type>event</Type>")
			sb.AppendLine("	<Name>Marker " & fields(1) & "</Name>")
			sb.AppendLine("	<Parameters>")
			sb.AppendLine("		<Parameter>")
			sb.AppendLine("			<Name />")
			sb.AppendLine("			<Value>" & fields(2) & "</Value>")
			sb.AppendLine("		</Parameter>")
			sb.AppendLine("	</Parameters>")
			sb.AppendLine("</CuePoint>")
		Loop

		sr.Close()
		sr.Dispose()

		Dim result As String = sb.ToString()
		Console.WriteLine(result)
	End Sub
End Class

Results in:

<CuePoint>
	<Time>52.000000</Time>
	<Type>event</Type>
	<Name>Marker  400.000000</Name>
	<Parameters>
		<Parameter>
			<Name />
			<Value> 1.3107711</Value>
		</Parameter>
	</Parameters>
</CuePoint>
<CuePoint>
	<Time>51.000000</Time>
	<Type>event</Type>
	<Name>Marker  401.000000</Name>
	<Parameters>
		<Parameter>
			<Name />
			<Value> 2.3107711</Value>
		</Parameter>
	</Parameters>
</CuePoint>
<CuePoint>
	<Time>55.000000</Time>
	<Type>event</Type>
	<Name>Marker  402.000000</Name>
	<Parameters>
		<Parameter>
			<Name />
			<Value> 3.3107711</Value>
		</Parameter>
	</Parameters>
</CuePoint>

Ok I apologize I must have not been clear. Ok so I have the text file already since I noticed a new text document is created through the code, so no new text file i need to open an existing one and convert it. Also the text document is code itself that I need to convert to a different version as an xml (also I have a lot of these types of text documents)

The example code of the original text document I will have: 52.000000, 400.000000, 1.3107711, 0

52.000000 = the value from the text i need converted to xml under <value>0<value>

160.000000 = the value from the text i need converted to xml under <value>1<value>

271.000000 = the value from the text i need converted to xml under <value>2<value>

All the above values repeat and vary at random but they will not be anything other than what I listed above.

400.000000 = null object I need this to NOT be included in xml

1.3107711 = time that I will need converted from text to the xml in format xml format being <time>1310</time>. Basically its 1.310 without a decimal and 4 less decimal places (7711 taken out). If for example the time is 10.3476544 then it will come out as 10347 (10.347 without decimal)

XML format of the time will be <time>(insert time here)</time> and i have many random time values from 1 to the hundreds that I need converted so I need to define time as a variable not as a specific like 1.310771 since it can be anything from 1 to possibly 1000.

0 = null object I need this to NOT be included in xml

Also the marker value in the xml can be anything as long as it has the <marker>(insert anything here)</marker>

hope that cleared up what each value means and what they can be.

I know this is a lot to ask and this is my last resort after my friend started having technical difficulties with his computer. I'm sorry if this is much.

If you can still help and you need info please ask and also if you need an entire file to see exactly how many lines I'm talking about I can upload it here (I think).

I don't understand what you're asking. Are you saying you need to read the text file and match it up to an existing XML file and modify the contents?

Sorry. What I'm saying is that I have the text file that I need to edit since the code you gave creates a new text document. I need that text document converted into a new xml file in the format mentioned before.

Just modify the code. I had it create the text file since I didn't have your file on my machine.

Imports System.IO
Imports System.Text

Public Class frmReadFile

	Private Shared Sub CreateSampleFile(ByVal outFile As String)
		Dim sb As New StringBuilder()
		sb.AppendLine("52.000000, 400.000000, 1.3107711, 0")
		sb.AppendLine("51.000000, 401.000000, 2.3107711, 0")
		sb.AppendLine("55.000000, 402.000000, 3.3107711, 0")
		Dim buffer() As Byte = ASCIIEncoding.UTF8.GetBytes(sb.ToString())
		If (File.Exists(outFile)) Then
			File.Delete(outFile)
		End If

		Dim fs As New FileStream(outFile, FileMode.Create)
		fs.Write(buffer, 0, buffer.Length)
		fs.Close()
		fs.Dispose()
	End Sub

	Private Shared Sub TxtToXML(ByVal inFile As String, ByVal outFile As String)
		Dim sr As New StreamReader(inFile)

		Dim sb As New StringBuilder()

		Do While sr.Peek() >= 0
			Dim line As String = sr.ReadLine()
			Dim fields() As String = line.Split(New [Char]() {","c}, System.StringSplitOptions.None)

			sb.AppendLine("<CuePoint>")
			sb.AppendLine("	<Time>" & fields(0).Trim() & "</Time>")
			sb.AppendLine("	<Type>event</Type>")
			sb.AppendLine("	<Name>Marker " & fields(1).Trim() & "</Name>")
			sb.AppendLine("	<Parameters>")
			sb.AppendLine("		<Parameter>")
			sb.AppendLine("			<Name />")
			sb.AppendLine("			<Value>" & fields(2).Trim() & "</Value>")
			sb.AppendLine("		</Parameter>")
			sb.AppendLine("	</Parameters>")
			sb.AppendLine("</CuePoint>")
		Loop

		sr.Close()
		sr.Dispose()

		Dim result As String = sb.ToString()
		If (File.Exists(outFile)) Then
			File.Delete(outFile)
		End If
		File.WriteAllText(outFile, sb.ToString())
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		'This is since I don't have your file. You dont run this line since you already have the file.
		CreateSampleFile("C:\testdata.txt")
		'This is the real work
		TxtToXML("C:\testdata.txt", "C:\testdata.xml")
	End Sub
End Class

Edited 7 Years Ago by sknake: n/a

Thing is my time varies in each line and I have hundreds of lines and lots of files. I uploaded an example so you can see exactly how many lines the file contains. Thank you for your support so far! I will add rep to you most likely when we have this worked out.

Attachments
52.000000, 400.000000, 1.3107711, 0
52.000000, 400.000000, 1.6341271, 0
160.000000, 400.000000, 2.0065759, 0
52.000000, 400.000000, 2.1501587, 0
271.000000, 400.000000, 2.441179, 0
271.000000, 400.000000, 2.8332198, 0
52.000000, 400.000000, 2.9914964, 0
52.000000, 400.000000, 3.5022672, 0
160.000000, 400.000000, 3.9381855, 0
52.000000, 400.000000, 4.222199, 0
52.000000, 400.000000, 4.5462352, 0
52.000000, 400.000000, 4.7101807, 0
160.000000, 400.000000, 5.0469834, 0
52.000000, 400.000000, 5.1553734, 0
160.000000, 400.000000, 5.550362, 0
160.000000, 400.000000, 5.6872554, 0
52.000000, 400.000000, 5.8262576, 0
271.000000, 400.000000, 6.2064843, 0
271.000000, 400.000000, 6.5273005, 0
52.000000, 400.000000, 6.8083209, 0
271.000000, 400.000000, 7.1682528, 0
271.000000, 400.000000, 7.3265067, 0
52.000000, 400.000000, 7.638298, 0
160.000000, 400.000000, 7.793332, 0
52.000000, 400.000000, 8.1033546, 0
52.000000, 400.000000, 8.4313364, 0
160.000000, 400.000000, 9.0543521, 0
52.000000, 400.000000, 9.3672999, 0
160.000000, 400.000000, 9.7253043, 0
160.000000, 400.000000, 9.8813133, 0
52.000000, 400.000000, 11.3503833, 0
52.000000, 400.000000, 11.7065057, 0
52.000000, 400.000000, 12.0394534, 0
52.000000, 400.000000, 12.3347595, 0
52.000000, 400.000000, 12.4774579, 0
52.000000, 400.000000, 12.6584102, 0
52.000000, 400.000000, 12.8304736, 0
52.000000, 400.000000, 13.001426, 0
52.000000, 400.000000, 13.1574123, 0
52.000000, 400.000000, 13.3355529, 0
52.000000, 400.000000, 13.5035347, 0
52.000000, 400.000000, 13.6725596, 0
52.000000, 400.000000, 13.8458929, 0
160.000000, 400.000000, 14.01553, 0
160.000000, 400.000000, 14.3664143, 0
160.000000, 400.000000, 14.518251, 0
52.000000, 400.000000, 14.656505, 0
160.000000, 400.000000, 14.8304732, 0
160.000000, 400.000000, 14.998591, 0
160.000000, 400.000000, 15.1574572, 0
52.000000, 400.000000, 15.2954844, 0
271.000000, 400.000000, 15.5315161, 0
52.000000, 400.000000, 15.6844412, 0
160.000000, 400.000000, 15.96655, 0
160.000000, 400.000000, 16.1064593, 0
160.000000, 400.000000, 16.2464819, 0
52.000000, 400.000000, 16.4223549, 0
52.000000, 400.000000, 16.7775475, 0
271.000000, 400.000000, 16.9506314, 0
271.000000, 400.000000, 17.1534885, 0
271.000000, 400.000000, 17.2800191, 0
271.000000, 400.000000, 17.4004953, 0
271.000000, 400.000000, 17.5581823, 0
52.000000, 400.000000, 17.7179328, 0
52.000000, 400.000000, 18.0244861, 0
271.000000, 400.000000, 18.2465495, 0
271.000000, 400.000000, 18.3525359, 0
271.000000, 400.000000, 18.5131934, 0
271.000000, 400.000000, 18.6794972, 0
52.000000, 400.000000, 18.8699507, 0
52.000000, 400.000000, 19.0286581, 0
271.000000, 400.000000, 19.6816965, 0
271.000000, 400.000000, 19.8025582, 0
271.000000, 400.000000, 19.9436239, 0
271.000000, 400.000000, 20.1024901, 0
52.000000, 400.000000, 20.2555739, 0
52.000000, 400.000000, 20.6622632, 0
271.000000, 400.000000, 20.8485897, 0
271.000000, 400.000000, 20.9906531, 0
271.000000, 400.000000, 21.113601, 0
271.000000, 400.000000, 21.15961, 0
52.000000, 400.000000, 21.15961, 0
160.000000, 400.000000, 21.3502676, 0
52.000000, 400.000000, 21.5101088, 0
271.000000, 400.000000, 21.6486575, 0
160.000000, 400.000000, 21.846594, 0
160.000000, 400.000000, 21.9905622, 0
52.000000, 400.000000, 22.127637, 0
160.000000, 400.000000, 22.3503127, 0
52.000000, 400.000000, 22.5660723, 0
271.000000, 400.000000, 22.7900858, 0
271.000000, 400.000000, 22.9077275, 0
52.000000, 400.000000, 23.0496549, 0
271.000000, 400.000000, 23.3947115, 0
271.000000, 400.000000, 23.537614, 0
160.000000, 400.000000, 23.7262307, 0
271.000000, 400.000000, 23.9585436, 0
160.000000, 400.000000, 24.0936909, 0
160.000000, 400.000000, 24.2657317, 0
52.000000, 400.000000, 24.4057997, 0
52.000000, 400.000000, 24.7057316, 0
271.000000, 400.000000, 24.8896772, 0
52.000000, 400.000000, 25.0478404, 0
160.000000, 400.000000, 25.3107202, 0
160.000000, 400.000000, 25.4546657, 0
52.000000, 400.000000, 25.6057314, 0
52.000000, 400.000000, 25.8300398, 0
52.000000, 400.000000, 25.9980216, 0
52.000000, 400.000000, 26.1687245, 0
160.000000, 400.000000, 26.3747335, 0
52.000000, 400.000000, 26.5339398, 0
160.000000, 400.000000, 26.7136677, 0
52.000000, 400.000000, 26.886162, 0
271.000000, 400.000000, 27.0783841, 0
271.000000, 400.000000, 27.246366, 0
271.000000, 400.000000, 27.3856856, 0
271.000000, 400.000000, 27.574257, 0
271.000000, 400.000000, 27.7597899, 0
52.000000, 400.000000, 27.9637354, 0
271.000000, 400.000000, 28.1665698, 0
52.000000, 400.000000, 28.461377, 0
271.000000, 400.000000, 28.6477262, 0
271.000000, 400.000000, 28.7887692, 0
271.000000, 400.000000, 28.9287692, 0
52.000000, 400.000000, 29.3742112, 0
52.000000, 400.000000, 29.7585876, 0
271.000000, 400.000000, 29.8838483, 0
271.000000, 400.000000, 30.0238483, 0
271.000000, 400.000000, 30.1639163, 0
52.000000, 400.000000, 30.5422609, 0
52.000000, 400.000000, 30.6808549, 0
271.000000, 400.000000, 31.0358662, 0
271.000000, 400.000000, 31.1748231, 0
271.000000, 400.000000, 31.3343015, 0
271.000000, 400.000000, 31.4769092, 0
52.000000, 400.000000, 31.6119432, 0
271.000000, 400.000000, 31.7838025, 0
160.000000, 400.000000, 31.8965236, 0
271.000000, 400.000000, 31.9869091, 0
52.000000, 400.000000, 32.1318977, 0
271.000000, 400.000000, 32.2877934, 0
52.000000, 400.000000, 32.5041425, 0
160.000000, 400.000000, 32.7988817, 0
160.000000, 400.000000, 32.9378385, 0
160.000000, 400.000000, 33.222555, 0
160.000000, 400.000000, 33.5148452, 0
160.000000, 400.000000, 33.814505, 0
160.000000, 400.000000, 34.1263644, 0
160.000000, 400.000000, 34.2498564, 0
160.000000, 400.000000, 34.4066137, 0
160.000000, 400.000000, 34.5339833, 0
160.000000, 400.000000, 35.0279288, 0
160.000000, 400.000000, 35.4338697, 0
160.000000, 400.000000, 35.7618742, 0
160.000000, 400.000000, 36.1359104, 0
160.000000, 400.000000, 36.4790169, 0
52.000000, 400.000000, 36.8060009, 0
160.000000, 400.000000, 36.9779963, 0
52.000000, 400.000000, 37.1369532, 0
271.000000, 400.000000, 37.5585858, 0
271.000000, 400.000000, 37.6519417, 0
52.000000, 400.000000, 37.8069984, 0
160.000000, 400.000000, 38.2269756, 0
52.000000, 400.000000, 38.5229619, 0
160.000000, 400.000000, 38.8869755, 0
160.000000, 400.000000, 39.0060911, 0
52.000000, 400.000000, 39.1499913, 0
271.000000, 400.000000, 39.5050479, 0
160.000000, 400.000000, 39.6459776, 0
271.000000, 400.000000, 39.7700365, 0
52.000000, 400.000000, 39.898109, 0
160.000000, 400.000000, 40.1780182, 0
160.000000, 400.000000, 40.3185625, 0
52.000000, 400.000000, 40.4570885, 0
271.000000, 400.000000, 40.6302404, 0
52.000000, 400.000000, 40.8470204, 0
271.000000, 400.000000, 41.0360226, 0
271.000000, 400.000000, 41.112077, 0
52.000000, 400.000000, 41.4550474, 0
160.000000, 400.000000, 41.6760678, 0
160.000000, 400.000000, 41.769061, 0
52.000000, 400.000000, 41.9259997, 0
271.000000, 400.000000, 42.3130745, 0
271.000000, 400.000000, 42.4540495, 0
52.000000, 400.000000, 42.5438907, 0
160.000000, 400.000000, 42.8788793, 0
160.000000, 400.000000, 42.9890834, 0
160.000000, 400.000000, 43.1100357, 0
52.000000, 400.000000, 43.250081, 0
271.000000, 400.000000, 43.5481082, 0
271.000000, 400.000000, 43.6622351, 0
160.000000, 400.000000, 43.7480628, 0
271.000000, 400.000000, 43.9510786, 0
52.000000, 400.000000, 44.1541851, 0
160.000000, 400.000000, 44.2791738, 0
52.000000, 400.000000, 44.4061805, 0
271.000000, 400.000000, 44.5801714, 0
160.000000, 400.000000, 44.8401714, 0
271.000000, 400.000000, 44.9691056, 0
271.000000, 400.000000, 45.0945931, 0
52.000000, 400.000000, 45.2539128, 0
160.000000, 400.000000, 45.6711689, 0
160.000000, 400.000000, 45.7941848, 0
52.000000, 400.000000, 45.9342527, 0
271.000000, 400.000000, 46.3381756, 0
271.000000, 400.000000, 46.4781528, 0
160.000000, 400.000000, 46.6191505, 0
271.000000, 400.000000, 46.870375, 0
271.000000, 400.000000, 46.9792865, 0
52.000000, 400.000000, 47.0872684, 0
160.000000, 400.000000, 47.4543204, 0
160.000000, 400.000000, 47.5702387, 0
160.000000, 400.000000, 47.681894, 0
52.000000, 400.000000, 47.8221661, 0
271.000000, 400.000000, 48.1343883, 0
271.000000, 400.000000, 48.2302159, 0
160.000000, 400.000000, 48.2561569, 0
271.000000, 400.000000, 48.2793542, 0
271.000000, 400.000000, 48.4442295, 0
160.000000, 400.000000, 50.9113264, 0
160.000000, 400.000000, 53.389353, 0
160.000000, 400.000000, 53.7974709, 0
160.000000, 400.000000, 54.1693982, 0
160.000000, 400.000000, 54.5023913, 0
160.000000, 400.000000, 54.668355, 0
160.000000, 400.000000, 54.8305318, 0
160.000000, 400.000000, 54.9674026, 0
160.000000, 400.000000, 55.1363594, 0
160.000000, 400.000000, 55.2933889, 0
160.000000, 400.000000, 55.4545226, 0
160.000000, 400.000000, 55.6503956, 0
160.000000, 400.000000, 55.80645, 0
160.000000, 400.000000, 55.9954068, 0
52.000000, 400.000000, 56.1653614, 0
52.000000, 400.000000, 56.368536, 0
52.000000, 400.000000, 56.5421868, 0
52.000000, 400.000000, 56.699579, 0
52.000000, 400.000000, 56.8674021, 0
52.000000, 400.000000, 57.0284678, 0
52.000000, 400.000000, 57.2141821, 0
52.000000, 400.000000, 57.3535244, 0
52.000000, 400.000000, 57.5260868, 0
52.000000, 400.000000, 57.6784904, 0
52.000000, 400.000000, 57.8503951, 0
52.000000, 400.000000, 58.0065855, 0
52.000000, 400.000000, 58.2000322, 0
52.000000, 400.000000, 58.3503949, 0
52.000000, 400.000000, 58.542413, 0
52.000000, 400.000000, 58.7103722, 0
52.000000, 400.000000, 58.8538642, 0
271.000000, 400.000000, 58.9583994, 0
271.000000, 400.000000, 59.1344537, 0
271.000000, 400.000000, 59.2941136, 0
271.000000, 400.000000, 59.4424809, 0
271.000000, 400.000000, 59.5994876, 0
271.000000, 400.000000, 59.7740681, 0
271.000000, 400.000000, 59.9422313, 0
271.000000, 400.000000, 60.0964716, 0
271.000000, 400.000000, 60.2542721, 0
271.000000, 400.000000, 60.4144308, 0
271.000000, 400.000000, 60.5842493, 0
271.000000, 400.000000, 60.7211654, 0
271.000000, 400.000000, 60.8943173, 0
271.000000, 400.000000, 61.0324578, 0
271.000000, 400.000000, 61.2066301, 0
160.000000, 400.000000, 61.4715053, 0
160.000000, 400.000000, 61.626516
Imports System.IO
Imports System.Text

Public Class frmReadFile


	Private Shared Sub TxtToXML(ByVal inFile As String, ByVal outFile As String)
		Dim sr As New StreamReader(inFile)

		Dim sb As New StringBuilder()

		Do While sr.Peek() >= 0
			Dim line As String = sr.ReadLine()
			Dim fields() As String = line.Split(New [Char]() {","c}, System.StringSplitOptions.None)

			sb.AppendLine("<CuePoint>")
			sb.AppendLine("	<Time>" & fields(0).Trim() & "</Time>")
			sb.AppendLine("	<Type>event</Type>")
			sb.AppendLine("	<Name>Marker " & fields(1).Trim() & "</Name>")
			sb.AppendLine("	<Parameters>")
			sb.AppendLine("		<Parameter>")
			sb.AppendLine("			<Name />")
			sb.AppendLine("			<Value>" & fields(2).Trim() & "</Value>")
			sb.AppendLine("		</Parameter>")
			sb.AppendLine("	</Parameters>")
			sb.AppendLine("</CuePoint>")
		Loop

		sr.Close()
		sr.Dispose()

		Dim result As String = sb.ToString()
		If (File.Exists(outFile)) Then
			File.Delete(outFile)
		End If
		File.WriteAllText(outFile, sb.ToString())
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		'This is since I don't have your file. Change this to the path on YOUR machine
		TxtToXML("C:\dotnetwin\example.txt", "C:\dotnetwin\example.xml")
		MessageBox.Show("Done")
	End Sub
End Class

It ran in under a second. Doesn't this do what you want?

Thank you so much! (had to fix one thing in script and that was switch fields 0 and 2) I was looking to find a command that did what (& fields(0).Trim() &) does.

One last thing. During the conversion is it possible to make the thing change a line such as (" <Time>" & fields(2).Trim() & "</Time>") to go from 1.3107711 to 1310 (cut off 7711 and take out decimal)? I need this done for each time value.

I know what i typed may look confusing so if need be i can clarify.

Edited 7 Years Ago by ktkevin1222: n/a

Ok I understand what decimal.Parse will do and the i believe (F4) will only leave 4 numbers but is there anyway i can do this to every time value?

That is almost what Im looking for. this last part I couldn't figure out. I need to have the same format except also get rid of the decimal. It seems obvious but i can't figure it out.

Also I need to convert 52.000000 to 0, 160.000000 to 1, and 271.000000 to 2. Haven't been able to do a convert or replace command correctly.

Edited 7 Years Ago by ktkevin1222: n/a

How are you doing the math here?
0-99 = 0
100-199 = 1
200-299 = 2 ?

If so:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim lst As New List(Of String)
		lst.Add("52.000000")
		lst.Add("160.000000")
		lst.Add("271.000000")
		For Each s In lst
			Dim i1 As Integer = GetInteger(Decimal.Parse(s))
			Console.WriteLine("Original Value: {0}", s)
			Console.WriteLine("New Value: {0:F0}", i1)
		Next
	End Sub

	Private Shared Function GetInteger(ByVal someDecimal As Decimal) As Integer
		If (someDecimal <= 0) Then
			Return 0
		End If
		Return Convert.ToInt32(Math.Floor(someDecimal / 100))
	End Function

Results in:

Original Value: 52.000000
New Value: 0
Original Value: 160.000000
New Value: 1
Original Value: 271.000000
New Value: 2

well i don't know about the math that's just how the code comes out. I need the xml to have the replaced values though and I need the time to not have the decimal.

Edited 7 Years Ago by ktkevin1222: n/a

This question has already been answered. Start a new discussion instead.