五千年(敝帚自珍)

主题:【原创】【老兵开源】一个可以计算你写的帖子有多少字的程序 -- 老兵帅客

共:💬27
分页树展主题 · 全看首页 上页
/ 2
下页 末页
          • 家园 老天!

            本来就是搞笑,居然真会有人上当!

            不好意思,得罪了。

            • 家园 老兵,消消气。我是跟你开玩笑的。

              我平常看你不像开不得玩笑之人,才会那样说的。你在技术上和人生经验上都是我的前辈,我哪里会对你不敬。不过以前谁说的对,网上说话不像面对面时,因为看不到表情,听不到语调,所以容易引起误解。今后我要多注意。再次给您赔不是,不要生气了好不好?

    • 家园 几点意见:你要是关心大家涨分的问题,将这个程序做成WEB吗?

      大家就不用下在什么.NET Framework,用什么csc编译了。

      另外,如果字数不够200,程序应该自动增加点“垃圾”内容,比如表情点看全图,标点符号(▲►????▒♀☼),图片什么的点看全图

      外链图片需谨慎,可能会被源头改

      这样对大家才有“帮助”,也可以把铁手气死过去!

      • 家园 如果有那样的东西出现,我会毫不犹豫的封。
        • 家园 只是玩笑 - Web版本,功能等同于Windows新版

          不过我还真写了一个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);

          }

          }

          }

          再次声明,这个只是用来玩玩,不要真的用来制造垃圾。

      • 家园 新版本在这里

        考虑到ASP.Net服务器还不是很普及,这个程序依然是个Windows Application,但是增加了自动填充能力,用户只需点击Auto Fill既可大功告成。其它说明同上。

        下面是全部源代码:

        using System;

        using System.Drawing;

        using System.Collections;

        using System.ComponentModel;

        using System.Windows.Forms;

        using System.Data;

        using System.Text;

        namespace TextLength

        {

        /// <summary>

        /// Summary description for Form1.

        /// </summary>

        public class MainForm : System.Windows.Forms.Form

        {

        private System.Windows.Forms.Label lblText;

        private System.Windows.Forms.TextBox txtText;

        private System.Windows.Forms.Button btnExit;

        private System.Windows.Forms.Label lblLength;

        private System.Windows.Forms.TextBox txtLength;

        private System.Windows.Forms.Button btnAutoFill;

        private const int minLength=200;

        private string message1="敬祝铁手万事如意、身体健康\n";

        private string message2="\n";

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.Container components = null;

        public MainForm()

        {

        //

        // Required for Windows Form Designer support

        //

        InitializeComponent();

        //

        // TODO: Add any constructor code after InitializeComponent call

        //

        }

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        protected override void Dispose( bool disposing )

        {

        if( disposing )

        {

        if (components != null)

        {

        components.Dispose();

        }

        }

        base.Dispose( disposing );

        }

        #region Windows Form Designer generated code

        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

        System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));

        this.lblText = new System.Windows.Forms.Label();

        this.txtText = new System.Windows.Forms.TextBox();

        this.btnExit = new System.Windows.Forms.Button();

        this.lblLength = new System.Windows.Forms.Label();

        this.txtLength = new System.Windows.Forms.TextBox();

        this.btnAutoFill = new System.Windows.Forms.Button();

        this.SuspendLayout();

        //

        // lblText

        //

        this.lblText.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

        this.lblText.Location = new System.Drawing.Point(24, 16);

        this.lblText.Name = "lblText";

        this.lblText.Size = new System.Drawing.Size(136, 16);

        this.lblText.TabIndex = 0;

        this.lblText.Text = "Please fill in the text:";

        //

        // txtText

        //

        this.txtText.Location = new System.Drawing.Point(16, 40);

        this.txtText.Multiline = true;

        this.txtText.Name = "txtText";

        this.txtText.ScrollBars = System.Windows.Forms.ScrollBars.Both;

        this.txtText.Size = new System.Drawing.Size(296, 176);

        this.txtText.TabIndex = 1;

        this.txtText.Text = "";

        this.txtText.TextChanged += new System.EventHandler(this.txtText_TextChanged);

        //

        // btnExit

        //

        this.btnExit.Location = new System.Drawing.Point(184, 264);

        this.btnExit.Name = "btnExit";

        this.btnExit.Size = new System.Drawing.Size(64, 23);

        this.btnExit.TabIndex = 3;

        this.btnExit.Text = "Exit";

        this.btnExit.Click += new System.EventHandler(this.btnExit_Click);

        //

        // lblLength

        //

        this.lblLength.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

        this.lblLength.Location = new System.Drawing.Point(20, 231);

        this.lblLength.Name = "lblLength";

        this.lblLength.Size = new System.Drawing.Size(96, 16);

        this.lblLength.TabIndex = 4;

        this.lblLength.Text = "Current length:";

        //

        // txtLength

        //

        this.txtLength.BackColor = System.Drawing.SystemColors.HighlightText;

        this.txtLength.Location = new System.Drawing.Point(124, 231);

        this.txtLength.Name = "txtLength";

        this.txtLength.ReadOnly = true;

        this.txtLength.TabIndex = 5;

        this.txtLength.Text = "";

        //

        // btnAutoFill

        //

        this.btnAutoFill.Location = new System.Drawing.Point(64, 264);

        this.btnAutoFill.Name = "btnAutoFill";

        this.btnAutoFill.Size = new System.Drawing.Size(64, 24);

        this.btnAutoFill.TabIndex = 6;

        this.btnAutoFill.Text = "Auto Fill";

        this.btnAutoFill.Click += new System.EventHandler(this.btnAutoFill_Click);

        //

        // MainForm

        //

        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

        this.ClientSize = new System.Drawing.Size(328, 302);

        this.Controls.Add(this.btnAutoFill);

        this.Controls.Add(this.txtLength);

        this.Controls.Add(this.lblLength);

        this.Controls.Add(this.btnExit);

        this.Controls.Add(this.txtText);

        this.Controls.Add(this.lblText);

        this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

        this.MaximizeBox = false;

        this.Name = "MainForm";

        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

        this.Text = "Text Length Detector";

        this.ResumeLayout(false);

        }

        #endregion

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        [STAThread]

        static void Main()

        {

        Application.Run(new MainForm());

        }

        private void btnExit_Click(object sender, System.EventArgs e)

        {

        Dispose();

        }

        private void txtText_TextChanged(object sender, System.EventArgs e)

        {

        this.txtLength.Text=Convert.ToString(this.txtText.TextLength);

        }

        private void btnAutoFill_Click(object sender, System.EventArgs e)

        {

        if(this.txtText.TextLength<minLength)

        {

        int difference=(minLength-this.txtText.TextLength)/(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();

        }

        }

        }

        }

      • 家园 【严正声明】我的目的是帮助大家高效率地发帖挣分,而不是制造垃圾

        有人良心大大地坏了。

      • 家园 或者我干脆做个填充器算了

        用户只需填上标题,剩下的就不用关心了。

        肚皮要笑破了。

        看来我需要举报点什么了。

分页树展主题 · 全看首页 上页
/ 2
下页 末页


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河