How do I finish this simple text/label code?

I’m nearly finished with my code but can’t grasp the last part. Code doesn’t fit so I had to use pastebin :S
Code posted below separately
https://pastebin.com/fU2G23LW

What is entered in the text field is “translated” to a different character displayed in the label.
I have the first 13 characters working but I currently can’t type any more characters after that.
I need someway to allow the user to type 4 additional characters at the end of the text field and have those 4 characters shown at the end of the label as well.
The 4 characters at the end of label will need to have a space before.

[h]First Part of Code (second part below)[/h]

[code]dim found as integer
dim producttype, cona, conb as string

'forces a dash
if len(partnumber.text) = 2 then
partnumber.Mask = “”
else
partnumber.Mask = “&&-&&&&&&&&&&&&&&”
end if

if Mid(partnumber.text, 1 , 2) = “P1” then
description.text = “Q-SERIES”
elseif Mid(partnumber.text, 1, 2) = “P3” then
description.text = “INFINIUM”
elseif Mid(partnumber.text, 1 , 2) = “C1” then
description.text = “CORNING”
else
description.text = “…”
end if

if Mid(partnumber.text, 4, 2) = “01” then
description.text = description.text + " " + “LC”
elseif Mid(partnumber.text, 4, 2) = “02” then
description.text = description.text + " " + “SC”
elseif Mid(partnumber.text, 4, 2) = “03” then
description.text = description.text + " " + “ST”
elseif Mid(partnumber.text, 4, 2) = “04” then
description.text = description.text + " " + “FC”
elseif Mid(partnumber.text, 4, 2) = “05” then
description.text = description.text + " " + “LCA”
elseif Mid(partnumber.text, 4, 2) = “06” then
description.text = description.text + " " + “SCA”
elseif Mid(partnumber.text, 4, 2) = “07” then
description.text = description.text + " " + “STA”
elseif Mid(partnumber.text, 4, 2) = “08” then
description.text = description.text + " " + “FCA”
elseif Mid(partnumber.text, 4, 2) = “09” then
description.text = description.text + " " + “SST”
elseif Mid(partnumber.text, 4, 2) = “10” then
description.text = description.text + " " + “RJF”
elseif Mid(partnumber.text, 4, 2) = “11” then
description.text = description.text + " " + “RJM”
elseif Mid(partnumber.text, 4, 2) = “12” then
description.text = description.text + " " + “905”
elseif Mid(partnumber.text, 4, 2) = “13” then
description.text = description.text + " " + “906”
elseif Mid(partnumber.text, 4, 2) = “14” then
description.text = description.text + " " + “D4”
elseif Mid(partnumber.text, 4, 2) = “21” then
description.text = description.text + " " + “LU1”
elseif Mid(partnumber.text, 4, 2) = “22” then
description.text = description.text + " " + “LFB”
elseif Mid(partnumber.text, 4, 2) = “24” then
description.text = description.text + " " + “LU2”
elseif Mid(partnumber.text, 4, 2) = “31” then
description.text = description.text + " " + “LU3”
elseif Mid(partnumber.text, 4, 2) = “39” then
description.text = description.text + " " + “CLC”
elseif Mid(partnumber.text, 4, 2) = “40” then
description.text = description.text + " " + “CSC”
elseif Mid(partnumber.text, 4, 2) = “41” then
description.text = description.text + " " + “CST”
elseif Mid(partnumber.text, 4, 2) = “42” then
description.text = description.text + " " + “CFC”
elseif Mid(partnumber.text, 4, 2) = “43” then
description.text = description.text + " " + “CLA”
elseif Mid(partnumber.text, 4, 2) = “44” then
description.text = description.text + " " + “CSA”
elseif Mid(partnumber.text, 4, 2) = “45” then
description.text = description.text + " " + “CFA”
elseif Mid(partnumber.text, 4, 2) = “78” then
description.text = description.text + " " + “LU4”
elseif Mid(partnumber.text, 4, 2) = “79” then
description.text = description.text + " " + “LCP”
elseif Mid(partnumber.text, 4, 2) = “80” then
description.text = description.text + " " + “LU5”
elseif Mid(partnumber.text, 4, 2) = “81” then
description.text = description.text + " " + “SFB”
end if

if Mid(partnumber.text, 6, 2) = “01” then
description.text = description.text + " " + “LC”
elseif Mid(partnumber.text, 6, 2) = “02” then
description.text = description.text + " " + “SC”
elseif Mid(partnumber.text, 6, 2) = “03” then
description.text = description.text + " " + “ST”
elseif Mid(partnumber.text, 6, 2) = “04” then
description.text = description.text + " " + “FC”
elseif Mid(partnumber.text, 6, 2) = “05” then
description.text = description.text + " " + “LCA”
elseif Mid(partnumber.text, 6, 2) = “06” then
description.text = description.text + " " + “SCA”
elseif Mid(partnumber.text, 6, 2) = “07” then
description.text = description.text + " " + “STA”
elseif Mid(partnumber.text, 6, 2) = “08” then
description.text = description.text + " " + “FCA”
elseif Mid(partnumber.text, 6, 2) = “09” then
description.text = description.text + " " + “SST”
elseif Mid(partnumber.text, 6, 2) = “10” then
description.text = description.text + " " + “RJF”
elseif Mid(partnumber.text, 6, 2) = “11” then
description.text = description.text + " " + “RJM”
elseif Mid(partnumber.text, 6, 2) = “12” then
description.text = description.text + " " + “905”
elseif Mid(partnumber.text, 6, 2) = “13” then
description.text = description.text + " " + “906”
elseif Mid(partnumber.text, 6, 2) = “14” then
description.text = description.text + " " + “D4”
elseif Mid(partnumber.text, 6, 2) = “21” then
description.text = description.text + " " + “LU1”
elseif Mid(partnumber.text, 6, 2) = “22” then
description.text = description.text + " " + “LFB”
elseif Mid(partnumber.text, 6, 2) = “24” then
description.text = description.text + " " + “LU2”
elseif Mid(partnumber.text, 6, 2) = “31” then
description.text = description.text + " " + “LU3”
elseif Mid(partnumber.text, 6, 2) = “39” then
description.text = description.text + " " + “CLC”
elseif Mid(partnumber.text, 6, 2) = “40” then
description.text = description.text + " " + “CSC”
elseif Mid(partnumber.text, 6, 2) = “41” then
description.text = description.text + " " + “CST”
elseif Mid(partnumber.text, 6, 2) = “42” then
description.text = description.text + " " + “CFC”
elseif Mid(partnumber.text, 6, 2) = “43” then
description.text = description.text + " " + “CLA”
elseif Mid(partnumber.text, 6, 2) = “44” then
description.text = description.text + " " + “CSA”
elseif Mid(partnumber.text, 6, 2) = “45” then
description.text = description.text + " " + “CFA”
elseif Mid(partnumber.text, 6, 2) = “78” then
description.text = description.text + " " + “LU4”
elseif Mid(partnumber.text, 6, 2) = “79” then
description.text = description.text + " " + “LCP”
elseif Mid(partnumber.text, 6, 2) = “80” then
description.text = description.text + " " + “LU5”
elseif Mid(partnumber.text, 6, 2) = “81” then
description.text = description.text + " " + “SFB”
end if[/code]

[h]Second part of code[/h]


if Mid(partnumber.text, 8, 1) = "A" then
  description.text = description.text + " " + "AA"
elseif Mid(partnumber.text, 8, 1) = "B" then
  description.text = description.text + " " + "AB"
elseif Mid(partnumber.text, 8, 1) = "S" then
  description.text = description.text + " " + "SX"
end if


if Mid(partnumber.text, 9, 1) = "1" then
  description.text = description.text + " " + "D1"
elseif Mid(partnumber.text, 9, 1) = "2" then
  description.text = description.text + " " + "D2"
elseif Mid(partnumber.text, 9, 1) = "3" then
  description.text = description.text + " " + "D3"
elseif Mid(partnumber.text, 9, 1) = "9" then
  description.text = description.text + " " + "D9"
elseif Mid(partnumber.text, 9, 1) = "J" then
  description.text = description.text + " " + "D5"
  
end if

if Mid(partnumber.text, 10, 1) = "A" then
  description.text = description.text + " " + "OM1"
elseif Mid(partnumber.text, 10, 1) = "B" then
  description.text = description.text + " " + "OM2"
elseif Mid(partnumber.text, 10, 1) = "C" then
  description.text = description.text + " " + "O2+"
elseif Mid(partnumber.text, 10, 1) = "D" then
  description.text = description.text + " " + "OM3"
elseif Mid(partnumber.text, 10, 1) = "E" then
  description.text = description.text + " " + "OM4"
elseif Mid(partnumber.text, 10, 1) = "F" then
  description.text = description.text + " " + "O4+"
elseif Mid(partnumber.text, 10, 1) = "G" then
  description.text = description.text + " " + "4++"
elseif Mid(partnumber.text, 10, 1) = "H" then
  description.text = description.text + " " + "OM5"
elseif Mid(partnumber.text, 10, 1) = "I" then
  description.text = description.text + " " + "OS2"
elseif Mid(partnumber.text, 10, 1) = "J" then
  description.text = description.text + " " + "A1"
elseif Mid(partnumber.text, 10, 1) = "K" then
  description.text = description.text + " " + "A2"
elseif Mid(partnumber.text, 10, 1) = "L" then
  description.text = description.text + " " + "B3"
elseif Mid(partnumber.text, 10, 1) = "M" then
  description.text = description.text + " " + "B2"
elseif Mid(partnumber.text, 10, 1) = "N" then
  description.text = description.text + " " + "SM"
  
end if


if Mid(partnumber.text, 11, 1) = "B" then
  description.text = description.text + " " + "BLU"
elseif Mid(partnumber.text, 11, 1) = "E" then
  description.text = description.text + " " + "ORG"
elseif Mid(partnumber.text, 11, 1) = "G" then
  description.text = description.text + " " + "GRN"
elseif Mid(partnumber.text, 11, 1) = "N" then
  description.text = description.text + " " + "BRN"
elseif Mid(partnumber.text, 11, 1) = "S" then
  description.text = description.text + " " + "SLT"
elseif Mid(partnumber.text, 11, 1) = "W" then
  description.text = description.text + " " + "WHT"
elseif Mid(partnumber.text, 11, 1) = "R" then
  description.text = description.text + " " + "RED"
elseif Mid(partnumber.text, 11, 1) = "K" then
  description.text = description.text + " " + "BLK"
elseif Mid(partnumber.text, 11, 1) = "Y" then
  description.text = description.text + " " + "YEL"
elseif Mid(partnumber.text, 11, 1) = "V" then
  description.text = description.text + " " + "VIO"
elseif Mid(partnumber.text, 11, 1) = "P" then
  description.text = description.text + " " + "ROS"
elseif Mid(partnumber.text, 11, 1) = "A" then
  description.text = description.text + " " + "AQU"
elseif Mid(partnumber.text, 11, 1) = "M" then
  description.text = description.text + " " + "MAG"
elseif Mid(partnumber.text, 11, 1) = "L" then
  description.text = description.text + " " + "LIM"
elseif Mid(partnumber.text, 11, 1) = "T" then
  description.text = description.text + " " + "TAN"
elseif Mid(partnumber.text, 11, 1) = "Q" then
  description.text = description.text + " " + "OLV"
  
end if


if Mid(partnumber.text, 12, 1) = "1" then
  description.text = description.text + " " + "RI SX"
elseif Mid(partnumber.text, 12, 1) = "2" then
  description.text = description.text + " " + "RI DX"
elseif Mid(partnumber.text, 12, 1) = "3" then
  description.text = description.text + " " + "LZ SX"
elseif Mid(partnumber.text, 12, 1) = "S" then
  description.text = description.text + " " + "PL SX"
elseif Mid(partnumber.text, 12, 1) = "D" then
  description.text = description.text + " " + "PL DX"
elseif Mid(partnumber.text, 12, 1) = "M" then
  description.text = description.text + " " + "MT RB"
elseif Mid(partnumber.text, 12, 1) = "A" then
  description.text = description.text + " " + "RI DF"
elseif Mid(partnumber.text, 12, 1) = "B" then
  description.text = description.text + " " + "PL DF"
elseif Mid(partnumber.text, 12, 1) = "R" then
  description.text = description.text + " " + "IO SX"
elseif Mid(partnumber.text, 12, 1) = "L" then
  description.text = description.text + " " + "LZ DF"
  
end if


if Mid(partnumber.text, 13, 1) = "0" then
  description.text = description.text + " " + "NL"
elseif Mid(partnumber.text, 13, 1) = "A" then
  description.text = description.text + " " + "AL"
elseif Mid(partnumber.text, 13, 1) = "B" then
  description.text = description.text + " " + "BL"
elseif Mid(partnumber.text, 13, 1) = "C" then
  description.text = description.text + " " + "LL"
  
end if

I highly suggest you read up on SELECT/CASE

SELECT CASE  Mid(partnumber.text, 13, 1) 
CASE  "0" 
  description.text = description.text + "  NL"
CASE   "A" 
  description.text = description.text + "  AL"
CASE  "B" 
  description.text = description.text + "  BL"
CASE  "C" 
  description.text = description.text + "  LL"
END SELECT

Thanks Dave. I will check out SELECT/CASE. I’m assuming it’s a alternative/cleaner way to achieve?

Not only cleaner… but in this type scenario… the PREFERRED method…
the amount of calculation drops… in just the snippet I posted, the MID calculation is done 1x instead of the 4x you had

You have this code in your project:

partnumber.Mask = “&&-&&&&&&&&&&&&&&”

That will limit the number of characters, maybe that’s the problem.

[quote=371301:@Chad Scr]I have the first 13 characters working but I currently can’t type any more characters after that.
I need someway to allow the user to type 4 additional characters at the end of the text field and have those 4 characters shown at the end of the label as well.
The 4 characters at the end of label will need to have a space before.[/quote]
Check your mask, format and LimitText values.

You should be able to type at least 3 more characters (mask in your code “&&-&&&&&&&&&&&&&&”)

[quote=371310:@John McKernon]You have this code in your project:

partnumber.Mask = “&&-&&&&&&&&&&&&&&”

That will limit the number of characters, maybe that’s the problem.[/quote]

I have four &'s at the end to account for the remaining four characters that would be entered in the text field.

[quote=371311:@Alberto De Poo]Check your mask, format and LimitText values.

You should be able to type at least 3 more characters (mask in your code “&&-&&&&&&&&&&&&&&”)[/quote]
Thanks, I set my LimitText to 17 and I can now type the last four characters in the text field.
But, I can’t seem to get it to display at the end of the label (with a space before)

Glad I was able to help. I’m more visual (examples) than only explaining with words. From your code, if you have this:

P1-0101A1AB10
you will get this:

Q-SERIES LC LC AA D1 0M1 BLU RI SX NL

I’m not sure if you want to have the last 4 characters, say ABCD to show as " ABCD" at the end of your label,

description.text = description.text + " " + Mid(partnumber.text, 14, 4)

I think that will do this:

P1-0101A1AB10ABCD Q-SERIES LC LC AA D1 0M1 BLU RI SX NL ABCD

I used mid and not right, that way you can have 1 or more characters (up to 4) at the end.

Thanks Alberto, that worked perfectly for what I needed!