chetan Allipur

chetan Allipur

  • NA
  • 541
  • 167.8k

Convert and give me VBA to c#

Jul 3 2017 2:40 AM
Here is my VBA code
 
sTemp = sGetDocVar("ParaNo1Text")
For i = 0 To cbxNumbPara1.ListCount - 1
If InStr(1, UCase(cbxNumbPara1.List(i)), UCase(sTemp)) = 1 Then
cbxNumbPara1.ListIndex = i
lblNumbPara1 = FirstWord(cbxNumbPara1.List(i))
End If
Next
If cbxNumbPara1.ListIndex < 0 Then cbxNumbPara1.ListIndex = 0
If lblNumbPara1 = "" Then lblNumbPara1 = "Not set"
 
Converted Code
 
sTemp = sGetDocVar("ParaNo1Text");
for (i = 0; i <= cbxNumbPara1.ListCount - 1; i++) {
if (Strings.InStr(1, Strings.UCase(cbxNumbPara1.List(i)), Strings.UCase(sTemp)) == 1) {
cbxNumbPara1.ListIndex = i;
lblNumbPara1 = FirstWord(cbxNumbPara1.List(i));
}
}
if (cbxNumbPara1.ListIndex < 0)
cbxNumbPara1.ListIndex = 0;
if (string.IsNullOrEmpty(lblNumbPara1))
lblNumbPara1 = "Not set";
 
I am getting errors
1)  Strings.InStr.
2)  Strings.UCase
3)   cbxNumbPara1.List(i)
 
Please anyone correct and send me the code 

Answers (2)