Count parameter as 001 -> 002 -> etc.

Count parameter as 001 -> 002 -> etc.

L.Greft
Advocate Advocate
338 Views
2 Replies
Message 1 of 3

Count parameter as 001 -> 002 -> etc.

L.Greft
Advocate
Advocate

I have a parameter called "QUANTITY" and want a messagebox to count to the value of the parameter.

The code I have now counts as 1 -> 2 -> 3 -> etc., but I want to count it as 001 -> 002 -> 003 -> etc..

 

Below you can find the code I use now, is it possible to edit the code so it does count as 001? The QTY_index should always have 3 characters, so if the QUANTITY is 54 the QTY_index should be 054. 

 

 

Dim FileName As String

For QTY_index As Integer = 1 To QUANTITY
	FileName = "PartInformation_" & QTY_index
	MessageBox.Show(FileName, "FileName")
Next

 

 

*Edit: I just thought about using this (below), but if someone has a better idea please let me know : )

Dim FileName As String
Dim Help As String

For QTY_index As Integer = 1 To QUANTITY
	If QUANTITY>= 0 And QUANTITY< 10 Then
		Help = "00"
	ElseIf QUANTITY>= 10 And QUANTITY< 100 Then
		Help = "0"
	Else
		Help = ""
	End If

	FileName = "PartInformation_" & Help & QTY_index
	MessageBox.Show(FileName, "FileName")
Next
Check out my ideas: https://autode.sk/2TKe6LH
0 Likes
Accepted solutions (1)
339 Views
2 Replies
Replies (2)
Message 2 of 3

fullevent
Advisor
Advisor
Accepted solution

Hi @L.Greft,

 

try this (untested)

Dim FileName As String

For QTY_index As Integer = 1 To QUANTITY
	FileName = "PartInformation_" & Format(QTY_index, "000")
	MessageBox.Show(FileName, "FileName")
Next

 

That should work as wanted.

Best regards,

 


Aleksandar Krstic
Produkt- und Projektmanager

Message 3 of 3

L.Greft
Advocate
Advocate

Thank you @fullevent, this works great!

Check out my ideas: https://autode.sk/2TKe6LH
0 Likes