2017-09-05 13 views
0

ここに条件を入れてもいいですか? 4桁の文字を入力した場合と同様に、 "F-"という接頭辞を付けます。C#文字数条件

try 
{ 
    Service1 ws = new Service1(); 
    if (e.KeyChar == (char)13 && button1.Enabled == true) 
    { 
     inputtxt = F.Text.ToString(); 
     showpic(inputtxt); 
     if (ws.VerifyEID(inputtxt) == false) 
     { 
      MessageBox.Show("You have entered an incorrect Employee ID. Please try again!", "Attendance Monitoring System", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
      F.Text = null; 
     } 



     else 
     { 
      panel1.Visible = false; 
      SqlToText(inputtxt); 
      ShowOffset(inputtxt); 
      if (BtnTimeIn.Visible == true) 
      { 
       BtnTimeIn.Focus(); 
      } 
      else 
      { 
       BtnTimeOut.Focus(); 
      } 
     } 

    } 

よろしくお願いします。よろしくお願いします。

+0

コードは完全ではないようで、現在の状態ではコンパイルされません。 – juharr

+0

これで、文字列の先頭に "f"という接頭辞を付けたいと思います。不完全な行がある場所に置いておきたいと思っています。if(inputtext = '? – Ben

+0

悪い、無視してください。私は助けてくれます – Chddz

答えて

0

あなたはあなたのコードでこれを挿入することができます。

inputtxt = inputtxt.StartsWith("F-") ? inputtxt : "F-" + inputtxt; 

をしかし、私は個人的に入力し、それらはより少ない文字を入力持っているものをユーザーのためのそれを明確にするために、テキストボックスにそのプレフィックスを持っているでしょう。