首页 新闻 搜索 专区 学院

下面的程序为什么会出现错误:类型“wincalc.calcForm”的声明上缺少 partial 修饰符;存在此类型的其他分

0
悬赏园豆:5 [待解决问题]
  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Linq;
  7 using System.Text;
  8 using System.Windows.Forms;
  9 
 10 namespace wincalc
 11 {
 12     public  class  calcForm : System.Windows.Forms.Form
 13     {
 14         private System.Windows.Forms.Button button1;
 15         private System.Windows.Forms.Button button2;
 16         private System.Windows.Forms.Button button3;
 17         private System.Windows.Forms.Button button4;
 18         private System.Windows.Forms.Button button5;
 19         private System.Windows.Forms.Button button6;
 20         private System.Windows.Forms.Button button7;
 21         private System.Windows.Forms.Button button8;
 22         private System.Windows.Forms.Button button9;
 23         private System.Windows.Forms.Button button10;
 24         private System.Windows.Forms.Button bClr;
 25         private System.Windows.Forms.Button bDot;
 26         private System.Windows.Forms.Button bPlus;
 27         private System.Windows.Forms.Button bSub;
 28         private System.Windows.Forms.Button bMul;
 29         private System.Windows.Forms.Button bDiv;
 30         private System.Windows.Forms.Button bEqu;
 31         private System.Windows.Forms.TextBox txtCalc;
 32         //以下是要添加的代码
 33         //定义变量
 34         Double dblAcc;
 35         Double dblSec;
 36         bool blnClear, blnFrstOpen;
 37         String strOper;
 38         //以上是添加的代码
 39         ///
 40         /// Required designer variable.
 41         ///
 42         private System.ComponentModel.Container components = null;
 43 
 44 
 45 
 46         public calcForm()
 47         {
 48             InitializeComponent();
 49             dblAcc = 0;
 50             dblSec = 0;
 51             blnFrstOpen = true;
 52             blnClear = true;
 53             strOper = new string('=', 1);
 54 
 55 
 56         }
 57         protected override void Dispose(bool disposing)
 58         {
 59             if (disposing)
 60             {
 61                 if (components!= null)
 62                 {
 63                     components.Dispose();
 64                 }
 65             }
 66             base.Dispose(disposing);
 67         }
 68         #region Windows Form Designer generated code
 69 
 70         private void InitializeComponent()
 71         {
 72             this.bPlus = new System.Windows.Forms.Button();
 73             this.bMul = new System.Windows.Forms.Button();
 74             this.bDot = new System.Windows.Forms.Button();
 75             this.txtCalc = new System.Windows.Forms.TextBox();
 76             this.bClr = new System.Windows.Forms.Button();
 77             this.bDiv = new System.Windows.Forms.Button();
 78             this.bSub = new System.Windows.Forms.Button();
 79             this.button8 = new System.Windows.Forms.Button();
 80             this.button9 = new System.Windows.Forms.Button();
 81             this.bEqu = new System.Windows.Forms.Button();
 82             this.button10 = new System.Windows.Forms.Button();
 83             this.button4 = new System.Windows.Forms.Button();
 84             this.button5 = new System.Windows.Forms.Button();
 85             this.button6 = new System.Windows.Forms.Button();
 86             this.button7 = new System.Windows.Forms.Button();
 87             this.button1 = new System.Windows.Forms.Button();
 88             this.button2 = new System.Windows.Forms.Button();
 89             this.button3 = new System.Windows.Forms.Button();
 90             this.SuspendLayout();
 91             //
 92             // bPlus
 93             //
 94             this.bPlus.BackColor = System.Drawing.SystemColors.Control;
 95             this.bPlus.ForeColor = System.Drawing.SystemColors.ControlText;
 96             this.bPlus.Location = new System.Drawing.Point(208, 112);
 97             this.bPlus.Name = "bPlus";
 98             this.bPlus.Size = new System.Drawing.Size(32, 80);
 99             this.bPlus.TabIndex = 1;
100             this.bPlus.Text = "+";
101             //以下是要添加的代码
102             bPlus.Click += new System.EventHandler(this.btn_Oper);
103             //以上是添加的代码
104             //
105             // bMul
106             //
107             this.bMul.Location = new System.Drawing.Point(160, 112);
108             this.bMul.Name = "bMul";
109             this.bMul.Size = new System.Drawing.Size(32, 32);
110             this.bMul.TabIndex = 1;
111             this.bMul.Text = "*";
112             //以下是要添加的代码
113             bMul.Click += new System.EventHandler(this.btn_Oper);
114             //以上是添加的代码
115             //
116             // bDot
117             //
118             this.bDot.ForeColor = System.Drawing.Color.Black;
119             this.bDot.Location = new System.Drawing.Point(112, 208);
120             this.bDot.Name = "bDot";
121             this.bDot.Size = new System.Drawing.Size(32, 32);
122             this.bDot.TabIndex = 0;
123             this.bDot.Text = ".";
124             //以下是要添加的代码
125             bDot.Click += new System.EventHandler(this.btn_clk);
126             //以上是添加的代码
127             //
128             // txtCalc
129             //
130             this.txtCalc.Location = new System.Drawing.Point(16, 24);
131             this.txtCalc.Name = "txtCalc";
132             this.txtCalc.ReadOnly = true;
133             this.txtCalc.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
134             this.txtCalc.Size = new System.Drawing.Size(224, 21);
135             this.txtCalc.TabIndex = 2;
136             this.txtCalc.Text = "";
137             //
138             // bClr
139             //
140             this.bClr.BackColor = System.Drawing.SystemColors.Control;
141             this.bClr.ForeColor = System.Drawing.SystemColors.ControlText;
142             this.bClr.Location = new System.Drawing.Point(208, 64);
143             this.bClr.Name = "bClr";
144             this.bClr.Size = new System.Drawing.Size(32, 32);
145             this.bClr.TabIndex = 0;
146             this.bClr.Text = "AC";
147             //以下是要添加的代码
148             bClr.Click += new System.EventHandler(this.btn_clr);
149             //以上是添加的代码
150             //
151             // bDiv
152             //
153             this.bDiv.Location = new System.Drawing.Point(160, 160);
154             this.bDiv.Name = "bDiv";
155             this.bDiv.Size = new System.Drawing.Size(32, 32);
156             this.bDiv.TabIndex = 1;
157             this.bDiv.Text = "/";
158             //以下是要添加的代码
159             bDiv.Click += new System.EventHandler(this.btn_Oper);
160             //以上是添加的代码
161             //
162             // bSub
163             //
164             this.bSub.Location = new System.Drawing.Point(160, 64);
165             this.bSub.Name = "bSub";
166             this.bSub.Size = new System.Drawing.Size(32, 32);
167             this.bSub.TabIndex = 1;
168             this.bSub.Text = "-";
169             //以下是要添加的代码
170             bSub.Click += new System.EventHandler(this.btn_Oper);
171             //以上是添加的代码
172             //
173             // button8
174             //
175             this.button8.Location = new System.Drawing.Point(16, 64);
176             this.button8.Name = "button8";
177             this.button8.Size = new System.Drawing.Size(32, 32);
178             this.button8.TabIndex = 0;
179             this.button8.Text = "7";
180             //以下是要添加的代码
181             button8.Click += new System.EventHandler(this.btn_clk);
182             //以上是添加的代码
183             //
184             // button9
185             //
186             this.button9.Location = new System.Drawing.Point(64, 64);
187             this.button9.Name = "button9";
188             this.button9.Size = new System.Drawing.Size(32, 32);
189             this.button9.TabIndex = 0;
190             this.button9.Text = "8";
191             //以下是要添加的代码
192             button9.Click += new System.EventHandler(this.btn_clk);
193             //以上是添加的代码
194             //
195             // bEqu
196             //
197             this.bEqu.BackColor = System.Drawing.SystemColors.Control;
198             this.bEqu.ForeColor = System.Drawing.SystemColors.ControlText;
199             this.bEqu.Location = new System.Drawing.Point(160, 208);
200             this.bEqu.Name = "bEqu";
201             this.bEqu.Size = new System.Drawing.Size(80, 32);
202             this.bEqu.TabIndex = 1;
203             this.bEqu.Text = "=";
204             //以下是要添加的代码
205             bEqu.Click += new System.EventHandler(this.btn_equ);
206             //以上是添加的代码
207             //
208             // button10
209             //
210             this.button10.Location = new System.Drawing.Point(112, 64);
211             this.button10.Name = "button10";
212             this.button10.Size = new System.Drawing.Size(32, 32);
213             this.button10.TabIndex = 0;
214             this.button10.Text = "9";
215             //以下是要添加的代码
216             button10.Click += new System.EventHandler(this.btn_clk);
217             //以上是添加的代码
218             //
219             // button4
220             //
221             this.button4.Location = new System.Drawing.Point(112, 160);
222             this.button4.Name = "button4";
223             this.button4.Size = new System.Drawing.Size(32, 32);
224             this.button4.TabIndex = 0;
225             this.button4.Text = "3";
226             //以下是要添加的代码
227             button4.Click += new System.EventHandler(this.btn_clk);
228             //以上是添加的代码
229             //
230             // button5
231             //
232             this.button5.Location = new System.Drawing.Point(16, 112);
233             this.button5.Name = "button5";
234             this.button5.Size = new System.Drawing.Size(32, 32);
235             this.button5.TabIndex = 0;
236             this.button5.Text = "4";
237             //以下是要添加的代码
238             button5.Click += new System.EventHandler(this.btn_clk);
239             //以上是添加的代码
240             //
241             // button6
242             //
243             this.button6.Location = new System.Drawing.Point(64, 112);
244             this.button6.Name = "button6";
245             this.button6.Size = new System.Drawing.Size(32, 32);
246             this.button6.TabIndex = 0;
247             this.button6.Text = "5";
248             //以下是要添加的代码
249             button6.Click += new System.EventHandler(this.btn_clk);
250             //以上是添加的代码
251             //
252             // button7
253             //
254             this.button7.Location = new System.Drawing.Point(112, 112);
255             this.button7.Name = "button7";
256             this.button7.Size = new System.Drawing.Size(32, 32);
257             this.button7.TabIndex = 0;
258             this.button7.Text = "6";
259             //以下是要添加的代码
260             button7.Click += new System.EventHandler(this.btn_clk);
261             //以上是添加的代码
262             //
263             // button1
264             //
265             this.button1.BackColor = System.Drawing.SystemColors.Control;
266             this.button1.ForeColor = System.Drawing.Color.Black;
267             this.button1.Location = new System.Drawing.Point(16, 208);
268             this.button1.Name = "button1";
269             this.button1.Size = new System.Drawing.Size(80, 32);
270             this.button1.TabIndex = 0;
271             this.button1.Text = "0";
272             //以下是要添加的代码
273             button1.Click += new System.EventHandler(this.btn_clk);
274             //以上是添加的代码
275             //
276             // button2
277             //
278             this.button2.Location = new System.Drawing.Point(16, 160);
279             this.button2.Name = "button2";
280             this.button2.Size = new System.Drawing.Size(32, 32);
281             this.button2.TabIndex = 0;
282             this.button2.Text = "1";
283             //以下是要添加的代码
284             button2.Click += new System.EventHandler(this.btn_clk);
285             //以上是添加的代码
286             //
287             // button3
288             //
289             this.button3.Location = new System.Drawing.Point(64, 160);
290             this.button3.Name = "button3";
291             this.button3.Size = new System.Drawing.Size(32, 32);
292             this.button3.TabIndex = 0;
293             this.button3.Text = "2";
294             //以下是要添加的代码
295             button3.Click += new System.EventHandler(this.btn_clk);
296             //以上是添加的代码
297             //
298             // calcForm
299             //
300             this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
301             this.ClientSize = new System.Drawing.Size(256, 261);
302             this.Controls.AddRange(new System.Windows.Forms.Control[] {
303 this.txtCalc,
304 this.bEqu,
305 this.bDiv,
306 this.bMul,
307 this.bSub,
308 this.bPlus,
309 this.bDot,
310 this.bClr,
311 this.button10,
312 this.button9,
313 this.button8,
314 this.button7,
315 this.button6,
316 this.button5,
317 this.button4,
318 this.button3,
319 this.button2,
320 this.button1});
321             this.Name = "calcForm";
322             this.Text = "计算器";
323             this.ResumeLayout(false);
324         }
325 
326         //以下是要添加的代码
327         //小数点的操作
328         private void btn_clk(object obj, EventArgs ea)
329         {
330             if (blnClear)
331                 txtCalc.Text = "";
332             Button b3 = (Button)obj;
333             txtCalc.Text += b3.Text;
334             if (txtCalc.Text == ".")
335                 txtCalc.Text = "0.";
336             dblSec = Convert.ToDouble(txtCalc.Text);
337             blnClear = false;
338         }
339         //程序开始点
340         private static void Main()
341         {
342             Application.Run(new calcForm());
343         }
344         private void btn_Oper(object obj, EventArgs ea)
345         {
346             Button tmp = (Button)obj;
347             strOper = tmp.Text;
348             if (blnFrstOpen)
349                 dblAcc = dblSec;
350             else
351                 calc();
352             blnFrstOpen = false;
353             blnClear = true;
354         }
355         //等号运算
356         private void btn_equ(object obj, EventArgs ea)
357         {
358             calc();
359         }
360         //所有运算操作
361         private void calc()
362         {
363             switch (strOper)
364             {
365                 case "+":
366                     dblAcc += dblSec; //加号运算
367                     break;
368                 case "-":
369                     dblAcc -= dblSec; //减号运算
370                     break;
371                 case "*":
372                     dblAcc *= dblSec; //乘号运算
373                     break;
374                 case "/":
375                     dblAcc /= dblSec; //除号运算
376                     break;
377             }
378             strOper = "="; //等号运算
379             blnFrstOpen = true;
380             txtCalc.Text = Convert.ToString(dblAcc);//将运算结果转换成字符类型,并输出
381             dblSec = dblAcc;//将运算数A的值放入运算数B中,以便后面运算
382         }
383         //清除按钮
384         private void btn_clr(object obj, EventArgs ea)
385         {
386             clear();
387         }
388         //清除按钮的操作
389         private void clear()
390         {
391             dblAcc = 0;
392             dblSec = 0;
393             blnFrstOpen = true;
394             txtCalc.Text = "";
395             txtCalc.Focus();//设置焦点为txtCalc
396         }
397         //以上是添加的代码
398     }
399 }
400 
401 
402 
403 
404 //private void button11_Click(object sender, EventArgs e)
405 // {
406 
407 // }
408 
409 
410         #endregion

而加上partial后错误更多

C#
foxing的主页 foxing | 初学一级 | 园豆:5
提问于:2012-06-17 23:31
< >
分享
所有回答(1)
1

你检查看,是否项目中还有别的cs文件里定义的类型是跟这个类型同名的(含名称空间在内)。

出现这个情况,一般都是有完全同名的类型定义导致的冲突。

无之无 | 园豆:5085 (大侠五级) | 2012-06-18 08:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册