I found this Visual Basic code on stack overflow. It is the closest thing I have
ID: 3868381 • Letter: I
Question
I found this Visual Basic code on stack overflow. It is the closest thing I have found that will give me what I need. Can this code be modified to open the text file: ("C:Academic Ethics.txt")), search for 11 Characters (d o n (a space) e v e r e t t), and display it in a label on the MainForm? If there is a way to display Dan Everett in the label that would be great, but just the 11 characters will do. I am really foggy on how and where to enter the 11 characters including the space. Your expert help would be greatly appreciated.
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load Here is rhe text file that I need to extract characters from;
Academic Ethics and Integrity Statement
Rio Salado College
Principles
As a leading institution of higher education, Rio Salado College strongly promotes core principles and values of Academic Ethics and Integrity. We believe in the central importance of ethical values and academic character virtues in achieving academic excellence. It is the duty and responsibility of all Rio Salado faculty, students, employees, clients, and partners to support ethical principles and values and to incorporate them into all practices of our core college principles of learning, innovating, and partnering.
As a foundation for all other ethical values, Rio Salado College is committed to excellence. We support high standards of quality and ethical behavior, pursued and practiced with diligence, conscientiousness, and discipline. We expect the best from ourselves and value the necessary human effort and courage, often in the “face of adversity,” in realizing our highest ideals.
Since becoming an educated person or a valuable employee is a personal accomplishment and achievement, we expect self-responsibility and accountability. As a core character virtue, self-responsibility empowers and motivates the learner and is the foundation of all meaningful achievements. Further, self-responsibility is necessary for mutual trust and dependability. Self-responsibility entails that we are held accountable for our actions and accept the appropriate consequences for our behavior.
As a center of learning and study, we critically value the pursuit of truth; further, we value truth as a necessary foundation for trust among us. Hence, we esteem honesty, integrity, and authenticity as character virtues in our institution, and we do not tolerate anything less. Through a number of ongoing institutional practices, we monitor and verify the integrity and authenticity of student assignments. In order to secure and maintain our public trust with the community, we understand that honesty and integrity are critical.
In our interactions with everyone, we strive for fairness and justice. Our judgments and our behaviors rest upon treating each other equitably and impartially. We are open to hearing and thoughtfully assessing each person’s perspective on an issue. Actions are judged and rewarded on their merits.
Consistent with our core value of inclusiveness, we believe in and practice social civility and mutual respect. We have compassion and concern for everyone, and maintain a social conscience regarding the human and environmental consequences of everything we do.
Finally, as an educational institution, we believe that the life-long acquisition of knowledge, the development of critical thinking skills, and ongoing critical self-r
Dim hash As List(Of String) = New List(Of String)(System.IO.File.ReadAllLines("C:Academic Ethics.txt"))
Dim Letters As String = lblLetters.Text
For Each item As String In hash
Dim Found As Boolean = True
For i = 0 To Letters.Length - 1
Dim OneCharacter As String = Letters.Substring(i, 1)
Dim itemToLower As String = item.ToLower()
If Not itemToLower.Contains(OneCharacter.ToLower()) Then
Found = False
Exit For
End If
Next i
If (Found) Then
'The given dictionary entry includes all the letters in the label. No more iterations will be performed
MsgBox(item)
Exit For
End If
Next
End Sub
Explanation / Answer
There are 2 different spellings you have given in the question. As separate characters you have given d o n (a space) e v e r e t t and as a name you have given Dan Everett. I am considering the 2nd one. Modified the code to look for all characters in "dan everett". It searches each line of the text and if any single line has all the characters specified, then it updates lblLetters. Since you have not mentioned the name of the label on your form, I presume it is lblLetters. If not, please use the correct name in the bolded coded. Code in bold are the changes. Hope it helps. If it does , please rate the answer . Thank you.
Dim hash As List(Of String) = New List(Of String)(System.IO.File.ReadAllLines("C:Academic Ethics.txt"))
Dim Letters As String = "dan everett"
For Each item As String In hash
Dim Found As Boolean = True
For i = 0 To Letters.Length - 1
Dim OneCharacter As String = Letters.Substring(i, 1)
Dim itemToLower As String = item.ToLower()
If Not itemToLower.Contains(OneCharacter.ToLower()) Then
Found = False
Exit For
End If
Next i
If (Found) Then
'The given dictionary entry includes all the letters in the label. No more iterations will be performed
lblLetters.Text = "Dan Everett"
Exit For
End If
Next
End Sub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.