Files
SuperSQLInjectionV1/SuperSQLInjection/FindString.cs

71 lines
2.1 KiB
C#
Raw Normal View History

2017-03-13 16:12:15 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
2017-03-13 16:12:15 +08:00
using System.Text;
using System.Windows.Forms;
namespace SuperSQLInjection
{
public partial class FindString : Form
{
public FindString()
{
InitializeComponent();
}
public int searchPoint = 0;
public TextBox txtbox = null;
private void btn_find_Click(object sender, EventArgs e)
2017-03-13 16:12:15 +08:00
{
//查找下一个
if (txtbox.Text == "")
{
//没内容
MessageBox.Show("查找内容为空,请输入查找内容", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
//有查找内容时
searchPoint = txtbox.Text.IndexOf(this.txt_key.Text, searchPoint);//用IndexOf索引
if (searchPoint < 0)
2017-03-13 16:12:15 +08:00
{
//没找到
MessageBox.Show("已到文本末尾,没有找到", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
searchPoint = 0;
}
else
{
//找到了,选中文本
txtbox.Focus();
txtbox.Select(searchPoint, this.txt_key.Text.Length);
searchPoint = searchPoint + this.txt_key.Text.Length;
this.Hide();
2017-03-13 16:12:15 +08:00
}
}
}
private void txt_key_TextChanged(object sender, EventArgs e)
2017-03-13 16:12:15 +08:00
{
int count = 0; //计数器
string search = this.txt_key.Text; //要查的字符串
if ("".Equals(search))
{
2017-03-13 16:12:15 +08:00
return;
}
for (int i = 0; i <= txtbox.Text.Length - search.Length; i++)
{
if (txtbox.Text.Substring(i, search.Length).ToLower() == search.ToLower())
{
count++;
}
}
this.label2.Text = "匹配:"+count.ToString();
2017-03-13 16:12:15 +08:00
}
}
}