| | |
If Statements!....for a newbie :)
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 5
Reputation:
Solved Threads: 0
Hey guys, I am having trouble with this If satement. heres the code that i have so far:
And here's what im trying to achieve (DL pic file attatchment). So If the two subject codes are the same the label is meant to read "students share 2 subjects" and if only one subject code matches then the label is meant to read "students share 1 subject" and if no subjects match then "students share 0 subjects".
I haven't named the textboxes or labels yet, so TextBox1 and TextBox2 are the subjects of Student 1 and TextBox3 and TextBox4 are the subjects of Student 2. Label6 is wehre the "students share x subject(s)"!!
Thank you very much for any help....I'm new to vb.net and appreciate any help given, Thank you very much!!!!
vb Syntax (Toggle Plain Text)
If Val(TextBox1.Text) = Val(TextBox3.Text) And Val(TextBox2.Text) = Val(TextBox4.Text) Then Label6.Text = "Students share 2 Subjects" End If If Val(TextBox1.Text) = Val(TextBox4.Text) And Val(TextBox2.Text) = Val(TextBox3.Text) Then Label6.Text = "Students share 2 Subjects" End If If Val(TextBox1.Text) = Val(TextBox3.Text) Or Val(TextBox2.Text) = Val(TextBox4.Text) Then Label6.Text = "Students share 1 Subject" If Val(TextBox2.Text) = Val(TextBox3.Text) Or Val(TextBox1.Text) = Val(TextBox4.Text) Then Label6.Text = "Students share 1 Subject" End If End If If Val(TextBox1.Text) <> Val(TextBox3.Text) And Val(TextBox2.Text) <> Val(TextBox4.Text) Then Label6.Text = "Students share 0 subjects" End If If Val(TextBox1.Text) <> Val(TextBox4.Text) And Val(TextBox2.Text) <> Val(TextBox3.Text) Then Label6.Text = "Students share 0 subjects" End If
And here's what im trying to achieve (DL pic file attatchment). So If the two subject codes are the same the label is meant to read "students share 2 subjects" and if only one subject code matches then the label is meant to read "students share 1 subject" and if no subjects match then "students share 0 subjects".
I haven't named the textboxes or labels yet, so TextBox1 and TextBox2 are the subjects of Student 1 and TextBox3 and TextBox4 are the subjects of Student 2. Label6 is wehre the "students share x subject(s)"!!
Thank you very much for any help....I'm new to vb.net and appreciate any help given, Thank you very much!!!!
Last edited by WolfPack; Mar 22nd, 2008 at 9:49 am. Reason: Added code tags. Use them when you post code. Also corrected indenting.
Hey there ferrier, couldn't you just shorten that whole piece of code down to just 3 statements? I've done it here (without using Val, you can add it if you want and such):
I think it works with every option if it doesn't then I'd have to sit down and work through it some more. Aye the middle elseif is just one huge statement lol.
Hope it works.
mhmm, looks like the VB.net highlighting syntax is incomplete
VBNET Syntax (Toggle Plain Text)
If TextBox1.Text = TextBox3.Text And TextBox2.Text = TextBox4.Text Or TextBox1.Text = TextBox4.Text And TextBox2.Text = TextBox3.Text Then Label6.Text = "Students share 2 subjects" ElseIf TextBox1.Text = TextBox3.Text And TextBox2.Text <> TextBox4.Text Or TextBox1.Text = TextBox4.Text And TextBox2.Text <> TextBox3.Text Or TextBox2.Text = TextBox4.Text And TextBox1.Text <> TextBox3.Text Or TextBox2.Text = TextBox3.Text And TextBox1.Text <> TextBox4.Text Then Label6.Text = "Students share 1 subject" Else Label6.Text = "Students share 0 subjects" End If
I think it works with every option if it doesn't then I'd have to sit down and work through it some more. Aye the middle elseif is just one huge statement lol.
Hope it works.
mhmm, looks like the VB.net highlighting syntax is incomplete
Stone In Focus - CoffeePHP - Onyx - Redpoint Network - Espresso
University of Exeter Student
Renewable Energy BSc
ap357@ex.ac.uk
University of Exeter Student
Renewable Energy BSc
ap357@ex.ac.uk
![]() |
Similar Threads
- help a newbie? mySQL find & replace (MySQL)
- Newbie in need of help!!! (C++)
- python newbie help (Python)
- Java newbie (Java)
- vb.net NEWBIE!! Triangle problem!! (VB.NET)
- A newbie needs help in Java ...... (Java)
- Can Anyone Help a Complete Newbie? (HTML and CSS)
Other Threads in the VB.NET Forum
- Previous Thread: Indent the C text in vb.net
- Next Thread: check box problem
Views: 1076 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2005 30minutes 2005 2008 access account application arithmetic array arrays basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dll dropdownlist excel file-dialog folder ftp google hardcopy highlighting image images inline insert listview login mobile ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox serial server soap sorting sql string syntax table tcp text textbox timer toolbox trim update updown usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





