主题:【原创】【老兵开源】一个可以计算你写的帖子有多少字的程序 -- 老兵帅客
不过我还真写了一个Web版,是用ASP.Net做的,有兴趣的可以玩玩,不过被铁手封了可别怪我。
下面是页面的源代码:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:Label id="lblText" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 32px" runat="server"
Width="192px" Height="16px">Please fill in the text:</asp:Label>
<asp:TextBox id="txtText" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 56px" runat="server"
Width="296px" Height="176px" TextMode="MultiLine"></asp:TextBox>
<asp:Label id="lblLength" style="Z-INDEX: 103; LEFT: 56px; POSITION: absolute; TOP: 248px"
runat="server" Width="128px" Height="16px">Current length:</asp:Label>
<asp:TextBox id="txtLength" style="Z-INDEX: 104; LEFT: 192px; POSITION: absolute; TOP: 248px"
runat="server" Width="120px" ReadOnly="True"></asp:TextBox>
<asp:Button id="btnAutoFill" style="Z-INDEX: 105; LEFT: 96px; POSITION: absolute; TOP: 304px"
runat="server" Width="81px" Height="24" Text="Auto Fill"></asp:Button>
<asp:Button id="btnGetLength" style="Z-INDEX: 106; LEFT: 216px; POSITION: absolute; TOP: 304px"
runat="server" Width="80px" Height="24" Text="Get Length"></asp:Button></FONT>
</form>
</body>
</HTML>
下面是对应的处理程序:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblText;
protected System.Web.UI.WebControls.TextBox txtText;
protected System.Web.UI.WebControls.Label lblLength;
protected System.Web.UI.WebControls.TextBox txtLength;
protected System.Web.UI.WebControls.Button btnAutoFill;
private const int minLength=200;
private string message1="敬祝铁手万事如意、身体健康\n";
protected System.Web.UI.WebControls.Button btnGetLength;
private string message2="\n";
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtText.TextChanged += new System.EventHandler(this.txtText_TextChanged);
this.btnAutoFill.Click += new System.EventHandler(this.btnAutoFill_Click);
this.btnGetLength.Click += new System.EventHandler(this.btnGetLength_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void txtText_TextChanged(object sender, System.EventArgs e)
{
}
private void btnAutoFill_Click(object sender, System.EventArgs e)
{
if(this.txtText.Text.Length<minLength)
{
int difference=(minLength-this.txtText.Text.Length)/(message1.Length+message2.Length)+1;
StringBuilder sb=new StringBuilder(this.txtText.Text);
sb.Append("\n");
for(int i=0;i<difference;i++)
{
sb.Append(message1);
sb.Append(message2);
}
this.txtText.Text=sb.ToString();
}
}
private void btnGetLength_Click(object sender, System.EventArgs e)
{
this.txtLength.Text=Convert.ToString(this.txtText.Text.Length);
}
}
}
再次声明,这个只是用来玩玩,不要真的用来制造垃圾。
- 相关回复 上下关系8
没什么,我今天是很生气,不过不是和你 老兵帅客 字6 2004-06-13 11:52:33
😁几点意见:你要是关心大家涨分的问题,将这个程序做成WEB吗? Highway 字344 2004-06-13 07:25:00
😁如果有那样的东西出现,我会毫不犹豫的封。 铁手 字0 2004-06-13 08:58:58
😄只是玩笑 - Web版本,功能等同于Windows新版
😄新版本在这里 老兵帅客 字6192 2004-06-13 08:25:13
😠【严正声明】我的目的是帮助大家高效率地发帖挣分,而不是制造垃圾 老兵帅客 字26 2004-06-13 07:45:43