我想设计拼写检查器,我的任务是逐个读取所有单词,如果表中已经存在一个单词,则在数据库表中进行搜索;如果该单词不在数据库中,则不执行任何操作;如果存在,则突出显示该单词。
我已经完成了这个公式,但是我不能理解问题出在哪里,因为它不能完美运行。
Dim lenoftxt As Integer
Dim i As Integer
Dim str As String
Dim tillword As String
tillword = ""
str = ""
i = 1
If Not RichTextBox1.Text = "" Then
lenoftxt = RichTextBox1.Text.Length
' MsgBox(lenoftxt)
For i = 1 To lenoftxt
str = Mid(RichTextBox1.Text, i, 1)
' MsgBox(str)
tillword = tillword & str
If str = " " Then
i = i + 1
tillword = Mid(tillword, 1, tillword.Length - 1)
' MsgBox(tillword)
romantranssql = "Select word from approved where word='" & tillword & "'"
MsgBox(romantranssql)
pth = My.Application.Info.DirectoryPath
romantransconn.ConnectionString = "Provider=Microsoft.ace.oledb.12.0; Data Source=" & pth & "\database.mdb; User Id=admin; Password=;"
romantransda = New OleDbDataAdapter(romantranssql, romantransconn)
romantransds = New DataSet
romantransda.Fill(romantransds, "DisplayCenterData")
romantransdt = romantransds.Tables("DisplayCenterData")
romantranscmb = New OleDbCommandBuilder(romantransda)
If Me.BindingContext(romantransdt).Count >= 1 Then
MsgBox("record found - " & tillword)
tillword = ""
End If
If Me.BindingContext(romantransdt).Count <= 0 Then
RichTextBox1.Select(i, tillword.Length)
RichTextBox1.SelectionColor = System.Drawing.Color.Red
tillword = ""
End If
End If
Next
End If
我正在使用的方法是在tillword
字符串中一个接一个地添加字符,如果找到空格,我认为该单词是完整的,然后在数据库表中搜索它。如果找到我什么都不做,如果找不到,我将其突出显示。
答案 0 :(得分:0)
我从我的php编程中获得了上帝的恩宠解决方案,并且效果很好
var MARK_UNREAD = false;
var ADD_UNSNOOZED_LABEL = false;
function getLabelName(i) {
return "Snooze/Snooze " + i + " days";
}
function setup() {
// Create the labels we’ll need for snoozing
GmailApp.createLabel("Snooze");
for (var i = 1; i <= 7; ++i) {
GmailApp.createLabel(getLabelName(i));
}
if (ADD_UNSNOOZED_LABEL) {
GmailApp.createLabel("Unsnoozed");
}
}
function moveSnoozes() {
var oldLabel, newLabel, page;
for (var i = 1; i <= 7; ++i) {
newLabel = oldLabel;
oldLabel = GmailApp.getUserLabelByName(getLabelName(i));
page = null;
// Get threads in "pages" of 100 at a time
while(!page || page.length == 100) {
page = oldLabel.getThreads(0, 100);
if (page.length > 0) {
if (newLabel) {
// Move the threads into "today’s" label
newLabel.addToThreads(page);
} else {
// Unless it’s time to unsnooze it
GmailApp.moveThreadsToInbox(page);
if (MARK_UNREAD) {
GmailApp.markThreadsUnread(page);
}
if (ADD_UNSNOOZED_LABEL) {
GmailApp.getUserLabelByName("Unsnoozed")
.addToThreads(page);
}
}
// Move the threads out of "yesterday’s" label
oldLabel.removeFromThreads(page);
}
}
}
}
在您的情况下输入英文字母,而不是sindhi阿拉伯字母 休假
Dim lenoftxt As Integer
Dim i As Integer
Dim str As String
Dim tillword As String
tillword = ""
str = ""
i = 1
If Not RichTextBox1.Text = "" Then
lenoftxt = RichTextBox1.Text.Length
' MsgBox(lenoftxt)
For i = 1 To lenoftxt
str = Mid(RichTextBox1.Text, i, 1)
' MsgBox(str)
If str = "ا" Or str = "ب" Or str = "ٻ" Or str = "ڀ" Or str = "ت" Or str = "ٿ" Or str = "ٽ" Or str = "ٺ" Or str = "ث" Or str = "پ" Or str = "ج" Or str = "ڄ" Or str = "ڃ" Or str = "چ" Or str = "ڇ" Or str = "ح" Or str = "خ" Or str = "د" Or str = "ڏ" Or str = "ڌ" Or str = "ڊ" Or str = "ڍ" Or str = "ذ" Or str = "ر" Or str = "ڙ" Or str = "ز" Or str = "س" Or str = "ش" Or str = "ص" Or str = "ض" Or str = "ط" Or str = "ظ" Or str = "ع" Or str = "غ" Or str = "ف" Or str = "ڦ" Or str = "ق" Or str = "ڪ" Or str = "ک" Or str = "گ" Or str = "ڳ" Or str = "ڱ" Or str = "ل" Or str = "م" Or str = "ن" Or str = "ڻ" Or str = "و" Or str = "ه" Or str = "ھ" Or str = "ي" Or str = "ئ" Or str = "آ" Or str = "۾" Or str = "۽" Or str = "ِ" Or str = "َ" Or str = "ُ" Or str = "ى" Then
tillword = tillword & str
Else
romantranssql = "Select word from approved where word='" & tillword & "'"
MsgBox(romantranssql)
pth = My.Application.Info.DirectoryPath
romantransconn.ConnectionString = "Provider=Microsoft.ace.oledb.12.0; Data Source=" & pth & "\database.mdb; User Id=admin; Password=;"
romantransda = New OleDbDataAdapter(romantranssql, romantransconn)
romantransds = New DataSet
romantransda.Fill(romantransds, "DisplayCenterData")
romantransdt = romantransds.Tables("DisplayCenterData")
romantranscmb = New OleDbCommandBuilder(romantransda)
If Me.BindingContext(romantransdt).Count >= 1 Then
MsgBox("record found - " & tillword)
tillword = ""
End If
If Me.BindingContext(romantransdt).Count <= 0 Then
Dim a As Integer
a = tillword.Length + 1
RichTextBox1.Select(i - a, tillword.Length)
' MsgBox(RichTextBox1.SelectedText & " selected text, not found and red")
RichTextBox1.SelectionColor = System.Drawing.Color.Red
MsgBox(RichTextBox1.SelectedText & "-" & i - a & "-" & tillword.Length)
ListBox1.Items.Add(tillword)
txtnormalword.Text = tillword
' Button5_Click_1(sender, New System.EventArgs())
tillword = ""
End If
End If
Next
End If
' tillword = ""