好吧,这是我关于这个主题的最后一个问题,所以我不会惹恼你们.好的,目前我的程序正在检查站点中是否有电子邮件.当他们是电子邮件时,它将逐行下载到textbox1.我只需要一些代码即可逐行(通过电子邮件发送电子邮件) 并检查该电子邮件是否在textbox4中.如果是,则向该地址发送带有其旁边产品密钥的电子邮件.如果没有匹配项,则将该电子邮件添加到textbox10.我想在一个连续的循环中做瘦.
Ok this is my final question on this topic so i don't annoy you guys. Ok currently my program check a site for emails. When their are emails it downloads the emails line by line to textbox1. i just need some code to go line by line (email by email) and check if that email is in textbox4. If it is then send an email to that address with the product key that is next to it. If there is no match then add that email to textbox10. I want to do thin in acontinuousloop.
Dim NoMatches As New List(Of String) Dim Found As Boolean Dim TextboxLine As String Dim Separator As Char = "/"c For Each Value As String In TextBox1.Lines Found = False For t As Integer = 0 To TextBox4.Lines.Length - 1 TextboxLine = TextBox4.Lines(t) If TextboxLine.ToLower.Contains(Value.ToLower) Then If TextboxLine.IndexOf(Separator) > -1 Then Dim Email As String = TextboxLine.Split(New Char() {Separator})(0).Trim(New Char() {"("c, ")"c}) Dim ProduktKey As String = TextboxLine.Split(New Char() {Separator})(1) Found = True End If Exit For End If Next If Found = False Then NoMatches.Add(Value) End If Next TextBox10.Lines = NoMatches.ToArray
推荐答案
为什么您怀疑不是所有行都在搜索过吗?您的代码中没有任何东西可以指示您已发生匹配,因此除非逐行跟踪,否则您将不知道是否搜索了所有行. 该代码当前将在文本框4的所有行中搜索文本框1的每一行,除非找到匹配项.如果找到与textbox1中的任何行都匹配的内容,它将停止搜索文本框4.因此,如果您以评估为依据,那就不是在搜索 NoMatches列表中缺少项目这一事实的所有行,因为它是匹配的,并且无论如何都不应该在其中.
Why do you suspect that not all lines are being searched? You have nothing in your code that would indicate to you that a match occurred, so unless you are tracing itline-by-line, you won't know whether or not all lines are searched. The code will currently search all lines in text box 4 for each line in text box 1, unless it finds a match. If it finds a match for any line from textbox1, it stops searching text box 4. So if you are basing your assessment that it is notsearching all lines on the fact that items are missing from theNoMatches list, that's becasue it matched, and the items shouldn't be in that lsit anyway.
我假设如果该电子邮件在textbox4中"表示如果
I am assuming that"if that email is in textbox4" meansif the result of
TextboxLine = TextBox4.Lines(t) 如果 TextboxLine.ToLower.Contains(Value.ToLower) 然后 如果 TextboxLine.IndexOf(Separator)> -1 然后 昏暗电子邮件为 字符串 = TextboxLine.Split(新 字符(){分隔符})(0).修剪(新建 字符(){"( c, ")" c}) 昏暗 ProduktKey 为 字符串 = TextboxLine.Split(新建 字符(){分隔符})(1) 找到= 真实 结束 如果
TextboxLine = TextBox4.Lines(t) If TextboxLine.ToLower.Contains(Value.ToLower) Then If TextboxLine.IndexOf(Separator) > -1 Then Dim Email As String = TextboxLine.Split(New Char() {Separator})(0).Trim(New Char() {"("c, ")"c}) Dim ProduktKey As String = TextboxLine.Split(New Char() {Separator})(1) Found = True End If
是将发现"设置为True.如果是这样,那么我怀疑问题"是比赛进行时您没有采取任何措施.您已经创建了两个变量(Email和ProductKey),并用部件对其进行了初始化. 行的内容,然后在If语句结束时(自动)将其丢弃.您使用来自找到"的否定结果来更新您的NoMatches列表,但是如果结果是肯定的,则从不执行任何操作.您需要添加代码才能发送 当您检测到行匹配时发送电子邮件.
is that Found is set to True. If so, then I suspect that the 'problem' is that you are not doing anything when the match occurs. You have created two variables (Email and ProductKey), initialised them with parts of the line, and then discarded them (automatically) when the If statement ends. You use a negative result from 'Found' to update your NoMatches list, but you never do anything if the result is positive. You need to add your code to send the email when you detect that the lines matched.
更多推荐
(最终)查找比赛问题
发布评论