ilogic text - remove character left and sometimes on the right

ilogic text - remove character left and sometimes on the right

dusan.naus.trz
Advisor Advisor
457 Views
6 Replies
Message 1 of 7

ilogic text - remove character left and sometimes on the right

dusan.naus.trz
Advisor
Advisor

when I use sValue = 12345 result = 11; 22

when I use sValue = 11 result = 12345; 22

How to remove character ";" ? Sometimes the character is on the left and sometimes on the right.

How to get the right result?

 


iProperties.Value("Custom", "A") = "12345; 11; 22"

'create a String type variable to hold the value of the first iProperty
Dim oA As String oA = iProperties.Value("Custom", "A") 'check to make sure it now contains a value other than "" If oA = "" Then MsgBox("The 'Plant Listing' iProperty was empty.", vbExclamation, "Empty iProperty") Exit Sub End If Dim sValue As String sValue = "12345" 'sValue = "11" If (iProperties.Value("Custom", "A").Contains(sValue)) Then ' MessageBox.Show("Bingo! " & sValue & " is in the list.", "iLogic") s1 = Replace(iProperties.Value("Custom", "A"), sValue, "") MessageBox.Show(s1, "Title") Else MessageBox.Show("Sorry, " & sValue & " is NOT in the list.", "iLogic") End If

 

0 Likes
Accepted solutions (1)
458 Views
6 Replies
Replies (6)
Message 2 of 7

dusan.naus.trz
Advisor
Advisor

I wanted to keep it simple, I used this. 

'sValue = "12345" & ";"
'sValue = "11" & ";"
sValue = "22" & ";"

Only with 22 it didn't work for me, there is no character ";"
Of course I have more numbers.

maybe i could use Else on that left side ";" 22

 

Does anyone have another idea?

0 Likes
Message 3 of 7

dusan.naus.trz
Advisor
Advisor

I simplified the example. I still haven't figured out how to remove the character ";" for number to the left or to the right.

 

'create a String type variable to hold the value of the first iProperty
Dim oA As String 
oA = iProperties.Value("Custom", "A")
'check to make sure it now contains a value other than ""
If oA = "" Then
	MsgBox("The 'Plant Listing' iProperty was empty.", vbExclamation, "Empty iProperty")
	Exit Sub
End If

Dim sValue As String
'sValue = "12345" & ";"
'sValue = "11" & ";"
'sValue = "22" & ";"
myparam = InputBox("12345; 11; 22", "Title", "Default Entry")
sValue = myparam

If (iProperties.Value("Custom", "A").Contains(sValue)) Then
'	MessageBox.Show("Bingo! " & sValue & " is in the list.", "iLogic")
s1 = Replace(iProperties.Value("Custom", "A"), sValue, "")
MessageBox.Show(s1, "Title")
'MessageBox.Show(Right(sValue ,+1), "Title")
Else
	MessageBox.Show("Sorry, " & sValue & " is NOT in the list.", "iLogic")
End If

 

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

I'm not sure what you trying to do. but maybe this might give you some ideas.

Dim values = "12345;11;22"

Dim list = values.Split(";").ToList()
myparam = InputListBox("Select value", list, oA, Title := "Title", ListName := "List")

list.Remove(myparam)
s1 = String.Join(";", list)

MsgBox(s1)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 7

dusan.naus.trz
Advisor
Advisor

Your code is nice, but I can't ToList values. I'm using iProperty and it can't transfer ToList values.

I needed something like this.
I think I made it too complicated.

I don't know if the code can be simplified? What do you think? Can there be another way?

(Just for clarification. This is not related to the code now. "myparam" is only a simplification. It will be filled via select pick, there will be more numbers and they will not be written but the values will be drawn with iProperties)

Dim oA As String
oA = iProperties.Value("Custom", "A")
If oA = "" Then
	MsgBox("The 'Plant Listing' iProperty was empty.", vbExclamation, "Empty iProperty")
	Exit Sub
End If

Dim sValue As String
myparam = InputBox("12345; 11; 22", "Title", "Default Entry")
sValue = myparam

If (iProperties.Value("Custom", "A").Contains(sValue)) Then
	If (iProperties.Value("Custom", "A").Contains(" " & sValue & ";")) Then
		s1 = Replace(iProperties.Value("Custom", "A"), " " & sValue & ";", "")
	ElseIf (iProperties.Value("Custom", "A").Contains("; " & sValue)) Then
		s1 = Replace(iProperties.Value("Custom", "A"), "; " & sValue, "")
	ElseIf (iProperties.Value("Custom", "A").Contains(sValue & ";")) Then
		s1 = Replace(iProperties.Value("Custom", "A"), sValue & ";", "")
	Else
		MessageBox.Show("Something went wrong", "Title")
	End If

	MessageBox.Show(s1, "Title")
	iProperties.Value("Custom", "A") = s1
Else
	MessageBox.Show("Sorry, " & sValue & " is NOT in the list.", "iLogic")
End If

 

0 Likes
Message 6 of 7

dusan.naus.trz
Advisor
Advisor
Accepted solution

I found that there are a total of 4 conditions. It is strange that there is no easier way to use this possibility of working with numbers and characters.

 

'iProperties.Value("Custom", "A") = "12345; 11; 22"
Dim oA As String
oA = iProperties.Value("Custom", "A")
If oA = "" Then
	MsgBox("The 'Plant Listing' iProperty was empty.", vbExclamation, "Empty iProperty")
	Exit Sub
End If
Dim sValue As String
myparam = InputBox("12345; 11; 22 and other numbers", "Title", "Default Entry")
sValue = myparam
If (iProperties.Value("Custom", "A").Contains(sValue)) Then
	If (iProperties.Value("Custom", "A").Contains(" " & sValue & ";")) Then' 11;
		s1 = Replace(iProperties.Value("Custom", "A"), " " & sValue & ";", "")
		'		MessageBox.Show("1", "Title")
	ElseIf (iProperties.Value("Custom", "A").Contains("; " & sValue)) Then'; 22
		s1 = Replace(iProperties.Value("Custom", "A"), "; " & sValue, "")
		'		MessageBox.Show("2", "Title")
	ElseIf (iProperties.Value("Custom", "A").Contains(sValue & ";")) Then'12345;
		s1 = Replace(iProperties.Value("Custom", "A"), sValue & ";", "")
		'		MessageBox.Show("3", "Title")
	ElseIf (iProperties.Value("Custom", "A").Contains(sValue)) Then'12345
		s1 = Replace(iProperties.Value("Custom", "A"), sValue, "")
		'		MessageBox.Show("4", "Title")
	Else
		MessageBox.Show("Something went wrong", "Title")
	End If
	'	MessageBox.Show(s1, "Title")
	iProperties.Value("Custom", "A") = s1
Else
	MessageBox.Show("Sorry, " & sValue & " is NOT in the list.", "iLogic")
End If

 

0 Likes
Message 7 of 7

dusan.naus.trz
Advisor
Advisor

Hi,
I am sending the finished result. Just for curiosity.

iLogic Open Top Assemblies and Numbers to Drawing

https://www.youtube.com/watch?v=j4ce8nACd1g&t=368s

0 Likes