本文介绍了文本框中的文本文件包含在VB.NET中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你好......首先抱歉我的英文不好,希望你能理解我会说什么,我是vb.net的初学者 我将为我的学校项目用vb.net创建简单的Porn Blocker Apllication。但是,我在文本文件/记事本中创建简单的色情词典时遇到问题。这个代码我有,但在这个代码中,我将在vb.net代码中逐个创建色情名称,此方法对我的应用程序无效。我将色情名称或色情类别名称放在一个文件(.txt文件)中。有人可以帮帮我吗? 先谢谢... 我试过的: 私有 Sub TextBox3_TextChanged(发件人作为 对象,e As EventArgs)句柄 TextBox3.TextChanged ListBox1.Items.Add(TextBox3.Text) 如果 TextBox3.Text.Contains( sex)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( hardsextube)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( tube8)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( keandra )然后 Tobat.ShowDialog()杀手() ElseIf TextBox3.Text.Contains( redtube)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( youjizz)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( spankwire)然后 Tobat.ShowDialog( ) killer() ElseIf TextBox3.Text.Contains( pornhub)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( fakku)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( xhamster)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( xvideos)然后 Tobat.ShowDialog() killer() ElseIf TextBox3 .Text.Contains( asian sex)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 亚洲性)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( asian xxx)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 亚洲xxx)然后 Tobat.ShowDialog()杀手() ElseIf TextBox3.Text.Contains( anal)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( Anal)然后 Tobat.ShowDialog() killer() ElseIf 文字Box3.Text.Contains( 滥用)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 滥用)然后 Tobat .ShowDialog() killer() ElseIf TextBox3.Text.Contains( Blonde)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 金发)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( Blowjob )然后 Tobat.ShowDialog()杀手() ElseIf TextBox3.Text.Contains( blowjob)然后 Tobat.ShowDialog()杀手() ElseIf TextBox3.Text .Contains( Bukkake)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( bukkake)然后 Tobat.ShowDialog( ) killer() ElseIf TextBox3.Text.Contains( brunete)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( Brunete )然后 Tobat.ShowDialog()杀手() ElseIf TextBox3.Text.Contains( creampie)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 体内射精)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( cumshot)然后 Tobat.ShowDialog () killer() ElseIf TextBox3.Text.Contains( Cumshot)然后 Tobat.ShowDialog()杀手( ) ElseIf TextBox3.Text.Contains( gangbang)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( Gangbang )然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( Gang Bang)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( gang bang)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains ( 同性恋)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 同性恋)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( hentai)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 跨种族)然后 Tobat.ShowDialog()杀手() ElseIf TextBox3.Text.Contains( Intterracial) 然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( japanese sex) Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( japan sex)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 日语性别)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( 日本性)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( seks)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( porn)然后 Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains( teen xxx)然后 Tobat.ShowDialog() killer() 结束 如果 结束 Sub 解决方案 使用Linq Intersect方法: Dim 行 As String ()= File.ReadAllLines(pathToFile) Dim x = textBox3.Text.Split( C).Intersect(lines) 如果 x.Count()> 0 然后 Tobat.ShowDialog()杀手() 结束 如果 Hello... First sorry for my bad english, hope you can understand what i'll say and i'm very beginner in vb.netI will create simple Porn Blocker Apllication with vb.net for my school project. But, i have problem when create simple porn dictionary in a text file/Notepad. This code i have, but in this code i will create porn name one by one in vb.net code where this method is not effective for my application. I will porn name or porn categories name in one file (.txt file). Can anyone help me please ?Thanks before...What I have tried:Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged ListBox1.Items.Add(TextBox3.Text) If TextBox3.Text.Contains("sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("hardsextube") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("tube8") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("keandra") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("redtube") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("youjizz") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("spankwire") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("pornhub") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("fakku") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("xhamster") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("xvideos") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("asian sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Asian sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("asian xxx") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Asian xxx") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("anal") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Anal") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("abuse") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Abuse") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Blonde") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("blonde") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Blowjob") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("blowjob") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Bukkake") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("bukkake") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("brunete") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Brunete") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("creampie") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Creampie") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("cumshot") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Cumshot") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("gangbang") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Gangbang") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Gang Bang") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("gang bang") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Gay") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("gay") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("hentai") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("interracial") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Intterracial") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("japanese sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("japan sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Japanese sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("Japan sex") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("seks") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("porn") Then Tobat.ShowDialog() killer() ElseIf TextBox3.Text.Contains("teen xxx") Then Tobat.ShowDialog() killer() End If End Sub 解决方案 Use the Linq Intersect method:Dim lines As String() = File.ReadAllLines(pathToFile)Dim x = textBox3.Text.Split(" "C).Intersect(lines)If x.Count() > 0 ThenTobat.ShowDialog()Killer()End If 这篇关于文本框中的文本文件包含在VB.NET中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-11 00:33