程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#發送短信源碼!

C#發送短信源碼!

編輯:關於C語言
只是初始的版本。朋友們可以看看其中的 一些技巧,如怎麼將進值轉換,中文轉換,字符移位處理。用MSCOMM怎麼發送和接收 數據,怎麼延時等! using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; namespace SendSMS {    ///    /// Form1 的摘要說明。    ///    public class FrmMain : System.Windows.Forms.Form    {       #region 控件的初始化=====================================================       private System.Windows.Forms.GroupBox groupBox1;       private System.Windows.Forms.ComboBox cboBox2;       private System.Windows.Forms.ComboBox cboBox1;       private System.Windows.Forms.Button btnCnn;       private System.Windows.Forms.Label label2;       private System.Windows.Forms.Label lbl;       private System.Windows.Forms.Label lbls;       private System.Windows.Forms.Button btnClose;       private System.Windows.Forms.Label lblcnnInfo;       private AxMSCommLib.AxMSComm MSCOMM;       private System.Windows.Forms.GroupBox groupBox2;       private System.Windows.Forms.Label lblCenter;       private System.Windows.Forms.TextBox txtCenter;       private System.Windows.Forms.Label lblVirtualDate;       private System.Windows.Forms.Label lblMobile;       private System.Windows.Forms.TextBox txtMobile;       private System.Windows.Forms.Label label1;       private System.Windows.Forms.StatusBar statusBar1;       private System.Windows.Forms.StatusBarPanel statusBarPanel1;       private System.Windows.Forms.StatusBarPanel statusBarPanel2;       private System.Windows.Forms.StatusBarPanel statusBarPanel3;       private System.Windows.Forms.Button btnSendSMS;       private System.Windows.Forms.TextBox txtSMS;       private System.Windows.Forms.ComboBox cboBox3;       private System.Windows.Forms.Label lblSMS;       private System.Windows.Forms.TextBox txtInput;       ///       /// 必需的設計器變量。       ///       private System.ComponentModel.Container components = null;       public FrmMain()       {          //          // Windows 窗體設計器支持所必需的          //          InitializeComponent();          //          // TOD 在 InitializeComponent 調用後添加任何構造函數代碼          //       }       ///       /// 清理所有正在使用的資源。       ///       protected override void Dispose( bool disposing )       {          if( disposing )          {             if (components != null)             {                components.Dispose();             }          }          base.Dispose( disposing );       }       #region Windows Form Designer generated code       ///       /// 設計器支持所需的方法 - 不要使用代碼編輯器修改       /// 此方法的內容。       ///       private void InitializeComponent()       {          System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmMain));          this.groupBox1 = new System.Windows.Forms.GroupBox();          this.MSCOMM = new AxMSCommLib.AxMSComm();          this.lblcnnInfo = new System.Windows.Forms.Label();          this.btnClose = new System.Windows.Forms.Button();          this.cboBox2 = new System.Windows.Forms.ComboBox();          this.cboBox1 = new System.Windows.Forms.ComboBox();          this.btnCnn = new System.Windows.Forms.Button();          this.label2 = new System.Windows.Forms.Label();          this.lbl = new System.Windows.Forms.Label();          this.lbls = new System.Windows.Forms.Label();          this.groupBox2 = new System.Windows.Forms.GroupBox();          this.txtInput = new System.Windows.Forms.TextBox();          this.lblSMS = new System.Windows.Forms.Label();          this.cboBox3 = new System.Windows.Forms.ComboBox();          this.btnSendSMS = new System.Windows.Forms.Button();          this.txtSMS = new System.Windows.Forms.TextBox();          this.label1 = new System.Windows.Forms.Label();          this.txtMobile = new System.Windows.Forms.TextBox();          this.lblMobile = new System.Windows.Forms.Label();          this.lblVirtualDate = new System.Windows.Forms.Label();          this.txtCenter = new System.Windows.Forms.TextBox();          this.lblCenter = new System.Windows.Forms.Label();          this.statusBar1 = new System.Windows.Forms.StatusBar();          this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();          this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();          this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();          this.groupBox1.SuspendLayout();          ((System.ComponentModel.ISupportInitialize)(this.MSCOMM)).BeginInit();          this.groupBox2.SuspendLayout();          ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();          ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();          ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();          this.SuspendLayout();          //          // groupBox1          //          this.groupBox1.Controls.Add(this.MSCOMM);          this.groupBox1.Controls.Add(this.lblcnnInfo);          this.groupBox1.Controls.Add(this.btnClose);          this.groupBox1.Controls.Add(this.cboBox2);          this.groupBox1.Controls.Add(this.cboBox1);          this.groupBox1.Controls.Add(this.btnCnn);          this.groupBox1.Controls.Add(this.label2);          this.groupBox1.Controls.Add(this.lbl);          this.groupBox1.Controls.Add(this.lbls);          this.groupBox1.Location = new System.Drawing.Point(8, 8);          this.groupBox1.Name = "groupBox1";          this.groupBox1.Size = new System.Drawing.Size(192, 328);          this.groupBox1.TabIndex = 1;          this.groupBox1.TabStop = false;          this.groupBox1.Text = "通訊設置";          //          // MSCOMM          //          this.MSCOMM.ContainingControl = this;          this.MSCOMM.Enabled = true;          this.MSCOMM.Location = new System.Drawing.Point(120, 264);          this.MSCOMM.Name = "MSCOMM";          this.MSCOMM.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("MSCOMM.OcxState")));          this.MSCOMM.Size = new System.Drawing.Size(38, 38);          this.MSCOMM.TabIndex = 9;          this.MSCOMM.OnComm += new System.EventHandler(this.MSCOMM_OnComm);          //          // lblcnnInfo          //          this.lblcnnInfo.AutoSize = true;          this.lblcnnInfo.Location = new System.Drawing.Point(8, 208);          this.lblcnnInfo.Name = "lblcnnInfo";          this.lblcnnInfo.Size = new System.Drawing.Size(0, 17);          this.lblcnnInfo.TabIndex = 8;          //          // btnClose          //          this.btnClose.Enabled = false;          this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Popup;          this.btnClose.ForeColor = System.Drawing.SystemColors.ControlText;          this.btnClose.Location = new System.Drawing.Point(96, 152);          this.btnClose.Name = "btnClose";          this.btnClose.TabIndex = 6;          this.btnClose.Text = "斷開(&D)";          this.btnClose.Click += new System.EventHandler(this.btnClose_Click);          //          // cboBox2          //          this.cboBox2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.cboBox2.Cursor = System.Windows.Forms.Cursors.PanSouth;          this.cboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;          this.cboBox2.Items.AddRange(new object[] {                                            "2400",                                            "4800",                                            "9600",                                            "19200",                                            "38400",                                            "57600",                                            "115200"});          this.cboBox2.Location = new System.Drawing.Point(78, 96);          this.cboBox2.Name = "cboBox2";          this.cboBox2.Size = new System.Drawing.Size(90, 20);          this.cboBox2.TabIndex = 5;          //          // cboBox1          //          this.cboBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.cboBox1.Cursor = System.Windows.Forms.Cursors.PanSouth;          this.cboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;          this.cboBox1.Items.AddRange(new object[] {                                            "COM1",                                            "COM2",                                            "COM3",                                            "COM4",                                            "COM5",                                            "COM6"});          this.cboBox1.Location = new System.Drawing.Point(78, 64);          this.cboBox1.Name = "cboBox1";          this.cboBox1.Size = new System.Drawing.Size(90, 20);          this.cboBox1.TabIndex = 4;          //          // btnCnn          //          this.btnCnn.FlatStyle = System.Windows.Forms.FlatStyle.Popup;          this.btnCnn.Location = new System.Drawing.Point(8, 152);          this.btnCnn.Name = "btnCnn";          this.btnCnn.TabIndex = 3;          this.btnCnn.Text = "連接(&C)";          this.btnCnn.Click += new System.EventHandler(this.btnCnn_Click);          //          // label2          //          this.label2.AutoSize = true;          this.label2.Location = new System.Drawing.Point(14, 96);          this.label2.Name = "label2";          this.label2.Size = new System.Drawing.Size(66, 17);          this.label2.TabIndex = 2;          this.label2.Text = "通訊速率:";          //          // lbl          //          this.lbl.AutoSize = true;          this.lbl.Location = new System.Drawing.Point(14, 72);          this.lbl.Name = "lbl";          this.lbl.Size = new System.Drawing.Size(66, 17);          this.lbl.TabIndex = 1;          this.lbl.Text = "通訊端口:";          //          // lbls          //          this.lbls.ForeColor = System.Drawing.Color.Red;          this.lbls.Location = new System.Drawing.Point(14, 23);          this.lbls.Name = "lbls";          this.lbls.Size = new System.Drawing.Size(144, 32);          this.lbls.TabIndex = 0;          this.lbls.Text = "請選擇正確的通訊端口,通訊速率一般為19200。";          //          // groupBox2          //          this.groupBox2.Controls.Add(this.txtInput);          this.groupBox2.Controls.Add(this.lblSMS);          this.groupBox2.Controls.Add(this.cboBox3);          this.groupBox2.Controls.Add(this.btnSendSMS);          this.groupBox2.Controls.Add(this.txtSMS);          this.groupBox2.Controls.Add(this.label1);          this.groupBox2.Controls.Add(this.txtMobile);          this.groupBox2.Controls.Add(this.lblMobile);          this.groupBox2.Controls.Add(this.lblVirtualDate);          this.groupBox2.Controls.Add(this.txtCenter);          this.groupBox2.Controls.Add(this.lblCenter);          this.groupBox2.Location = new System.Drawing.Point(200, 8);          this.groupBox2.Name = "groupBox2";          this.groupBox2.Size = new System.Drawing.Size(312, 328);          this.groupBox2.TabIndex = 2;          this.groupBox2.TabStop = false;          this.groupBox2.Text = "短信";          //          // txtInput          //          this.txtInput.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.txtInput.Enabled = false;          this.txtInput.Location = new System.Drawing.Point(200, 40);          this.txtInput.Multiline = true;          this.txtInput.Name = "txtInput";          this.txtInput.Size = new System.Drawing.Size(96, 120);          this.txtInput.TabIndex = 11;          this.txtInput.Text = "";          //          // lblSMS          //          this.lblSMS.AutoSize = true;          this.lblSMS.ForeColor = System.Drawing.Color.Red;          this.lblSMS.Location = new System.Drawing.Point(16, 304);          this.lblSMS.Name = "lblSMS";          this.lblSMS.Size = new System.Drawing.Size(0, 17);          this.lblSMS.TabIndex = 10;          //          // cboBox3          //          this.cboBox3.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.cboBox3.Cursor = System.Windows.Forms.Cursors.PanSouth;          this.cboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;          this.cboBox3.Items.AddRange(new object[] {                                            "00 - 沒有 ",                                            "47 - 6小時",                                            "90 - 12小時",                                            "A7 - 1天",                                            "A8 - 2天",                                            "A9 - 3天",                                            "AA - 4天",                                            "AB - 5天",                                            "AC - 6天",                                            "AD - 7天"});          this.cboBox3.Location = new System.Drawing.Point(16, 88);          this.cboBox3.Name = "cboBox3";          this.cboBox3.Size = new System.Drawing.Size(176, 20);          this.cboBox3.TabIndex = 9;          //          // btnSendSMS          //          this.btnSendSMS.Enabled = false;          this.btnSendSMS.FlatStyle = System.Windows.Forms.FlatStyle.Popup;          this.btnSendSMS.ForeColor = System.Drawing.SystemColors.ControlText;          this.btnSendSMS.Location = new System.Drawing.Point(184, 296);          this.btnSendSMS.Name = "btnSendSMS";          this.btnSendSMS.TabIndex = 8;          this.btnSendSMS.Text = "發送(&S)";          this.btnSendSMS.Click += new System.EventHandler(this.btnSendSMS_Click);          //          // txtSMS          //          this.txtSMS.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.txtSMS.Location = new System.Drawing.Point(16, 184);          this.txtSMS.Multiline = true;          this.txtSMS.Name = "txtSMS";          this.txtSMS.Size = new System.Drawing.Size(288, 104);          this.txtSMS.TabIndex = 7;          this.txtSMS.Text = "";          //          // label1          //          this.label1.AutoSize = true;          this.label1.Location = new System.Drawing.Point(16, 168);          this.label1.Name = "label1";          this.label1.Size = new System.Drawing.Size(208, 17);          this.label1.TabIndex = 6;          this.label1.Text = "短信內容:(內容不能超過104個字符)";          //          // txtMobile          //          this.txtMobile.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.txtMobile.Location = new System.Drawing.Point(16, 136);          this.txtMobile.MaxLength = 11;          this.txtMobile.Name = "txtMobile";          this.txtMobile.Size = new System.Drawing.Size(176, 21);          this.txtMobile.TabIndex = 5;          this.txtMobile.Text = "";          this.txtMobile.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtMobile_KeyPress);          //          // lblMobile          //          this.lblMobile.AutoSize = true;          this.lblMobile.Location = new System.Drawing.Point(16, 120);          this.lblMobile.Name = "lblMobile";          this.lblMobile.Size = new System.Drawing.Size(178, 17);          this.lblMobile.TabIndex = 4;          this.lblMobile.Text = "發送手機號:(例:13121011900)";          //          // lblVirtualDate          //          this.lblVirtualDate.AutoSize = true;          this.lblVirtualDate.Location = new System.Drawing.Point(16, 72);          this.lblVirtualDate.Name = "lblVirtualDate";          this.lblVirtualDate.Size = new System.Drawing.Size(79, 17);          this.lblVirtualDate.TabIndex = 2;          this.lblVirtualDate.Text = "短信有效期:";          //          // txtCenter          //          this.txtCenter.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));          this.txtCenter.ForeColor = System.Drawing.SystemColors.ControlText;          this.txtCenter.Location = new System.Drawing.Point(16, 40);          this.txtCenter.MaxLength = 14;          this.txtCenter.Name = "txtCenter";          this.txtCenter.Size = new System.Drawing.Size(176, 21);          this.txtCenter.TabIndex = 1;          this.txtCenter.Text = "+8613010112500";          this.txtCenter.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtCenter_KeyPress);          //          // lblCenter          //          this.lblCenter.AutoSize = true;          this.lblCenter.Location = new System.Drawing.Point(16, 24);          this.lblCenter.Name = "lblCenter";          this.lblCenter.Size = new System.Drawing.Size(208, 17);          this.lblCenter.TabIndex = 0;          this.lblCenter.Text = "短信中心號碼:(例:+8613010112500)";          //          // statusBar1          //          this.statusBar1.Cursor = System.Windows.Forms.Cursors.Hand;          this.statusBar1.Location = new System.Drawing.Point(0, 339);          this.statusBar1.Name = "statusBar1";          this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {                                                                    this.statusBarPanel1,                                                                    this.statusBarPanel2,                                                                    this.statusBarPanel3});          this.statusBar1.ShowPanels = true;          this.statusBar1.Size = new System.Drawing.Size(518, 24);          this.statusBar1.TabIndex = 3;          //          // statusBarPanel1          //          this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;          this.statusBarPanel1.Icon = ((System.Drawing.Icon)(resources.GetObject("statusBarPanel1.Icon")));          this.statusBarPanel1.Width = 31;          //          // statusBarPanel2          //          this.statusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;          this.statusBarPanel2.Width = 10;          //          // statusBarPanel3          //          this.statusBarPanel3.Width = 300;          //          // FrmMain          //          this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);          this.ClIEntSize = new System.Drawing.Size(518, 363);          this.Controls.Add(this.statusBar1);          this.Controls.Add(this.groupBox2);          this.Controls.Add(this.groupBox1);          this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;          this.MaximizeBox = false;          this.Name = "FrmMain";          this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;          this.Text = "短信群發系統..";          this.Load += new System.EventHandler(this.FrmMain_Load);          this.groupBox1.ResumeLayout(false);          ((System.ComponentModel.ISupportInitialize)(this.MSCOMM)).EndInit();          this.groupBox2.ResumeLayout(false);          ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();          ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();          ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();          this.ResumeLayout(false);       }       #endregion              ///       /// 應用程序的主入口點。       ///       [STAThread]       static void Main()       {          Application.Run(new FrmMain());       }       private void FrmMain_Load(object sender, System.EventArgs e)       {          this.cboBox1.Text="COM1";          this.cboBox2.Text="19200";          this.cboBox3.Text="A7 - 1天";          StatusBar();       }       #endregion       #region 手機與電腦連接和斷開事件=========================================       private void btnCnn_Click(object sender, System.EventArgs e)       {                    lblcnnInfo.Text="";          btnClose.Enabled =false;                 if (MSCOMM.PortOpen)          {             MessageBox.Show("端口已打開!","提示信息");          }          else          {                MSCOMM.PortOpen =true;             lblcnnInfo.Text="COM1已打開!";          }                    MSCOMM.InBufferCount = 0;          string strTemp="AT\r";          int T = Environment.TickCount;          int L;          string Buffer = "";          MSCOMM.Output = strTemp;                                 do             {             System.Windows.Forms.Application.DoEvents();             Console.WriteLine(Environment.TickCount - T );             lblcnnInfo.Text = "COM1 已打開," +"\r"+ "正在連接手機 ...";             Buffer += MSCOMM.Input;             L=Buffer.IndexOf("OK\r\n");          } while(L == -1 && Environment.TickCount - T <=2500);                    if (L!=-1)          {             btnCnn.Enabled=false;             btnClose.Enabled =true;             btnSendSMS.Enabled =true;             lblcnnInfo.Text = "COM1 已打開," + (char)13 + "連接手機成功!";             }          else          {             btnCnn.Enabled =true;             btnClose.Enabled =false;             MSCOMM.PortOpen =false;             btnSendSMS.Enabled =false;             lblcnnInfo.Text = "COM1 已打開," + (char)13 + "連接手機失敗!";                          }       }       private void btnClose_Click(object sender, System.EventArgs e)       {          if (MSCOMM.PortOpen)          {             MSCOMM.PortOpen =false;          }          btnCnn.Enabled =true;          btnClose.Enabled =false;          btnSendSMS.Enabled =false;          lblcnnInfo.Text = "COM1關閉, 已斷開手機的連接!";       } #endregion          #region 發送短信=========================================================       private void btnSendSMS_Click(object sender, System.EventArgs e)       {          lblSMS.Text="";          if(this.txtCenter.Text.Trim()=="")          {                       MessageBox.Show("提示:請輸入短信中心服務號碼!","短信發送");             this.txtCenter.Focus();             return;                    }          else if(this.txtMobile.Text.Trim()=="")          {             MessageBox.Show("提示:請輸入要發送的手機號!","短信發送");             this.txtMobile.Focus();             return;          }          else if(this.txtSMS.Text.Trim()=="")          {             MessageBox.Show("提示:請輸入要發送的短信內容!","短信發送");             this.txtSMS.Focus();             return;          }                    //將沒字轉換成16進制                    string strInput=txtSMS.Text;          string txt="";          string strTemp="";          for (int i = 0; i < strInput.Length; i++)          {             string str = "0000" + ((int)strInput).ToString("X");             txt += str.Substring(str.Length - 4);          }                                                //有效期          string cbo =this.cboBox3.Text;          cbo=cbo.Substring(0,2);          strInput =txt;          strTemp = strTemp + "08"; //SMSC地址信息的長度(91683110301405F0共八位字節)          strTemp = strTemp + "91"; //SMSC地址格式(TON/NPI)          strTemp = strTemp + strTOstr(txtCenter.Text.Substring(1));         //SMSC地址(8613010341500南京的短信服務中心號碼)          strTemp = strTemp + "11" ; //基本參數(TP-MTI/VFP)( 發送,接收為84)          strTemp = strTemp + "00" ; //MR Message Reference          strTemp = strTemp + "0D" ; //目標SIM卡號碼長度(683159717456F4按阿拉伯數字個數計)          strTemp = strTemp + "91" ; //同上          strTemp = strTemp + "68";          strTemp = strTemp + strTOstr(txtMobile.Text);         //要發送的手機號          strTemp = strTemp + "00"; //普通GSM類型,點到點方式          strTemp = strTemp + "08"; //UCS2編碼          strTemp = strTemp + cbo;         //有效期          string SMSLength = (txt.Length / 2).ToString("X");                 strTemp=strTemp + SMSLength;          strTemp=strTemp + txt;          strTemp = strTemp + (char)26;          // MSCOMM.Output = "AT+CMGF=0" + vbCr '以Pdu模式發送短信                    MSCOMM.Output = "AT+CMGS=" + (15 + txtSMS.Text.Length * 2) + (char)13;                    Thread.Sleep(2000);          MSCOMM.Output = strTemp;          lblSMS.Text="正在發送手機短信...";                    int T = Environment.TickCount;          int L;          string Buffer = "";                              do             {             System.Windows.Forms.Application.DoEvents();             Console.WriteLine(Environment.TickCount - T );             Buffer += MSCOMM.Input;             L=Buffer.IndexOf("OK\r\n");          } while(L == -1 && Environment.TickCount - T <=5500);                    if (L!=-1)          {             lblSMS.Text = "短信發送成功!";             }          else          {             lblSMS.Text = "短信發送失敗!";                          }       }       #endregion       #region 輸入校驗處理=====================================================       private void txtCenter_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)       {          if("+0123456789".IndexOf(e.KeyChar) == -1 && e.KeyChar !=(char)8 )          {             e.Handled = true ;          }       }       private void txtMobile_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)       {          if("0123456789".IndexOf(e.KeyChar) == -1 && e.KeyChar !=(char)8)          {             e.Handled = true ;          }                 } #endregion       #region 手機號移位處理===================================================       string strTOstr(string txt)       {          txt=txt+"F";          string txt2="";              for (int i = 1; i < txt.Length; i=i+2)          {             txt2 = txt2 + txt.Substring(i,1);             txt2 = txt2 + txt.Substring(i-1,1);                 }          return txt2;       }       #endregion       #region MSCOMM 返回的信息放入文本框 txtInput 中==========================       private void MSCOMM_OnComm(object sender, System.EventArgs e)       {          txtInput.Text=(string)MSCOMM.Input;       }       #endregion       #region 狀態欄處理=======================================================       private void StatusBar()       {          this.statusBarPanel1.Text ="版權所有 2004-2008";          this.statusBarPanel2.Text = "設計:Super ";          this.statusBarPanel3.Text = "網址: http://www.wsoft.cn";       }       #endregion       } }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved