windows程序设计代码(程序设计代码大全)
admin 发布:2022-12-19 11:55 120
本篇文章给大家谈谈windows程序设计代码,以及程序设计代码大全对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、c#windows窗体应用的一个程序设计。希望写出代码来。验证代码后采纳。
- 2、C#windows窗体程序编程中点击确定弹出新窗口的代码怎么写
- 3、windows程序设计的 两个里随便一个的代码
- 4、简述windows应用程序设计的基本步骤?
c#windows窗体应用的一个程序设计。希望写出代码来。验证代码后采纳。
题目中说明中的第一步:偶数*2,奇数*1 但是示例中的员工等级是偶数单乘的是1,我的代码中员工等级的处理方式和员工号一致,如果需要调整,在Calc(string xx)方法中注释的else位置修改。
图片中是窗口截图。代码如下:
namespace Calc
{
partial class Form1
{
/// summary
/// 必需的设计器变量。
/// /summary
private System.ComponentModel.IContainer components = null;
/// summary
/// 清理所有正在使用的资源。
/// /summary
/// param name="disposing"如果应释放托管资源,为 true;否则为 false。/param
protected override void Dispose(bool disposing)
{
if (disposing (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// summary
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// /summary
private void InitializeComponent()
{
this.txtNumber = new System.Windows.Forms.TextBox();
this.txtPwd = new System.Windows.Forms.TextBox();
this.txtLevel = new System.Windows.Forms.TextBox();
this.txtValCode = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txtInput = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtNumber
//
this.txtNumber.Location = new System.Drawing.Point(102, 68);
this.txtNumber.Name = "txtNumber";
this.txtNumber.ReadOnly = true;
this.txtNumber.Size = new System.Drawing.Size(126, 21);
this.txtNumber.TabIndex = 0;
//
// txtPwd
//
this.txtPwd.Location = new System.Drawing.Point(102, 105);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.ReadOnly = true;
this.txtPwd.Size = new System.Drawing.Size(126, 21);
this.txtPwd.TabIndex = 0;
//
// txtLevel
//
this.txtLevel.Location = new System.Drawing.Point(102, 136);
this.txtLevel.Name = "txtLevel";
this.txtLevel.ReadOnly = true;
this.txtLevel.Size = new System.Drawing.Size(126, 21);
this.txtLevel.TabIndex = 0;
//
// txtValCode
//
this.txtValCode.Location = new System.Drawing.Point(102, 173);
this.txtValCode.Name = "txtValCode";
this.txtValCode.ReadOnly = true;
this.txtValCode.Size = new System.Drawing.Size(126, 21);
this.txtValCode.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(55, 71);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 4;
this.label1.Text = "工号";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(55, 108);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 5;
this.label2.Text = "密码";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(55, 139);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 12);
this.label3.TabIndex = 6;
this.label3.Text = "级别";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(55, 176);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(41, 12);
this.label4.TabIndex = 7;
this.label4.Text = "验证码";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(55, 31);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(29, 12);
this.label5.TabIndex = 8;
this.label5.Text = "工号";
//
// txtInput
//
this.txtInput.Location = new System.Drawing.Point(102, 28);
this.txtInput.Name = "txtInput";
this.txtInput.Size = new System.Drawing.Size(126, 21);
this.txtInput.TabIndex = 1;
this.txtInput.Leave += new System.EventHandler(this.txtInput_Leave);
this.txtInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInput_KeyPress);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(263, 241);
this.Controls.Add(this.txtInput);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtValCode);
this.Controls.Add(this.txtLevel);
this.Controls.Add(this.txtPwd);
this.Controls.Add(this.txtNumber);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtNumber;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.TextBox txtValCode;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txtLevel;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtInput;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Calc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
txtInput.Focus();
}
private void txtInput_Leave(object sender, EventArgs e)
{
string content = txtInput.Text.Trim();
Calc(content);
}
private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
{
int charInt = (int)e.KeyChar;
if (charInt == 8 || charInt ==13)
{
string content = txtInput.Text.Trim();
Calc(content);
}
}
private void Calc(string content)
{
if (string.IsNullOrEmpty(content))
{
MessageBox.Show("请输入工号。");
txtInput.SelectAll();
return;
}
if (content.Length 11)
{
MessageBox.Show("输入的工号格式不正确。");
txtInput.SelectAll();
return;
}
string number = content.Substring(0, 6);
string pwd = content.Substring(7, 4);
string level = content[10].ToString();
txtNumber.Text = number;
txtPwd.Text = pwd;
txtLevel.Text = level;
//计算验证码
char[] numberChar = number.ToCharArray();
int result = 0;
for (int i = 0; i numberChar.Length + 1; i++)
{
if (i numberChar.Length)
{
int calcNumber = int.Parse(numberChar[i] + "");
int element = (calcNumber) % 2 == 0 ? calcNumber * 2 : calcNumber;
if (element 10)
element = int.Parse(element.ToString()[1] + "") + 1;
result += element;
}
else //级别校验,级别值为1 2 3 4 9按照规则计算结果不会超过10
{
int levelInt = int.Parse(level);
result += levelInt % 2 == 0 ? levelInt * 2 : levelInt;
}
}
result = CalcUntilSingleNumber(result);
txtValCode.Text = result + "";
}
private int CalcUntilSingleNumber(int number)
{
int result = 0;
string resultString = number.ToString();
if (resultString.Length 1)
{
char[] stringChar = resultString.ToCharArray();
foreach (char item in stringChar)
{
result += int.Parse(item + "");
}
if (result = 10)
result = CalcUntilSingleNumber(result);
}
else
{
result = number;
}
return result;
}
}
}
C#windows窗体程序编程中点击确定弹出新窗口的代码怎么写
1.先说跳转到网页,c#中是如何实现的。
写一句代码就可以了:
system.diagnostics.process.start(yoururladdrstr);
如果指定使用ie打开的话,可以写成:
system.diagnostics.process.start("iexplore.exe",
yoururladdrstr);
所以,明白了这个,就是在你的菜单栏对应的选项中的click事件中,添加上面的代码,即可。
其中yoururladdrstr设置你自己所需的url地址;
详情和原理,可以参考我的帖子:
【已解决】c#中调用资源管理器(explorer.exe)打开指定文件夹
+
并选中指定文件
+
调用(系统默认的播放类)软件(如wmp)打开(播放歌曲等)文件
(这里不给贴地址,所以请自己用google搜标题,即可找到帖子地址)
windows程序设计的 两个里随便一个的代码
windows程序设计的 两个里随便一个的代码
武魂分为两大类,一
类是器武魂,一类是兽
武魂。顾名思义,以器具
为武魂者,就是器武魂,
以动物为武魂
者,就是
兽武魂。
相对来说,器
武魂包含范围更
大,大多数人也都是
器武魂,而器武魂中
无法修炼的武魂也要比兽武魂的比例更大。
简述windows应用程序设计的基本步骤?
计算机程序设计基本步骤:\x0d\x0a(1)创建界面。程序的界面必须在一开始就设计好,否则在后期将很难进行修改。因此,是使用Windows提供的默认皮肤(见图1)还是自己编写皮肤,需要最早进行构思。注意:如果是一个整体的软件,需要先进行软件功能设置。\x0d\x0a(2)设置属性。这个是通用的方法,作用和“创建程序界面”差不多,基本方法就是“属性窗口、代码(对象名称.属性名称=属性值)”。\x0d\x0a(3)编写代码。完成程序理论设计之后,就开始编写程序代码了,具体代码与程序本身有关。\x0d\x0a(4)保存工程。设计完毕之后首先需要把工程保存下来,最好是每一次修改都保存源工程和修改后的工程,以便日后在遇到错误时快速恢复。\x0d\x0a(5)测试程序。完成修改之后要及时测试,发现已有的问题,创建了可执行程序之后就很难再修改了。\x0d\x0a(6)创建可执行程序(脚本)。完成工程之后就可以创建出一个可执行程序(或脚本)了。此时计算机程序已经设计完毕。
windows程序设计代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于程序设计代码大全、windows程序设计代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:网站开源代码是什么(网站程序源代码)
- 下一篇:微橙代码怎么样(微橙科技有限公司)
相关推荐
- 05-09网页代码,网页代码快捷键
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
- 05-06在线html执行代码(html怎么运行)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06代码源软件库(程序代码库)[20240506更新]
- 05-06点击弹出密码代码(点击弹出密码代码错误)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接