Guest Stefkov Posted September 18, 2007 Share Posted September 18, 2007 I saw your post in the MPT Odwin but I thought it i put what I've got maybe it'd be easier to help? What I've got is what you see below the main screen for entering details. Entering a surname into the surname text bx and then pressing the ? should bring up the details of what you searched in the list box next to it. I'm a noob in all this so bear with me Private Sub CmdSearchSurname_Click() Dim s As Student Dim StudentChannel As Integer Dim Studentpos As Integer Dim FoundStudent As Boolean FoundStudent = False Studentpos = 1 StudentChannel = FreeFile Open StudentFile For Random As StudentChannel Len = StudentLength Get StudentChannel, Studentpos, s Do While Not EOF(StudentChannel) If Trim(s.Surname) = Trim(TxtSurname.Text) Then LstStudentSurnameSearch.AddItem s.Forename End If Loop If FoundStudent = False Then MsgBox "There are no students with this surname" End If I think that it's all right until I get to the 'If trim' etc. It's opened the file, got the position of the first student then all its details. If the surname searched is the same as the one entered into the text box then... That's where I'm stuck (if it's all actually made sense up to now) What I've got there is crashing the program ( ) so help would be appreciated a lot. If you can't help, no worries. Link to comment Share on other sites More sharing options...
Shino Posted September 19, 2007 Share Posted September 19, 2007 What's the error description? And can you please indent the code so I can read it better, its a bit confusing. Link to comment Share on other sites More sharing options...
theguyfromspark Posted September 19, 2007 Share Posted September 19, 2007 It's possibly a null reference error, try checking that s and s.Surname (in that order) are not equal to Nothing before you attempt the trim. Link to comment Share on other sites More sharing options...
Mr_Odwin Posted September 19, 2007 Share Posted September 19, 2007 No idea. Good luck! Feel free to upload all your source code and it'll make it easier for us to check. Link to comment Share on other sites More sharing options...
theguyfromspark Posted September 19, 2007 Share Posted September 19, 2007 BTW, is this for a course? Because you really should be doing .NET these days... VB6 sucks arse and always has! Link to comment Share on other sites More sharing options...
Guest Stefkov Posted September 19, 2007 Share Posted September 19, 2007 My college uses VB6, they just do, I don't think they gave a reason. I posted that forgetting that I coulld go and see my teacher in the morning, which I did and it all seems so simple... Link to comment Share on other sites More sharing options...
Shino Posted September 19, 2007 Share Posted September 19, 2007 My college uses VB6, they just do, I don't think they gave a reason.I posted that forgetting that I coulld go and see my teacher in the morning, which I did and it all seems so simple... So its solved? Can you post the code, I'm curious. Link to comment Share on other sites More sharing options...
Mr_Odwin Posted September 19, 2007 Share Posted September 19, 2007 BTW, is this for a course? Because you really should be doing .NET these days... VB6 sucks arse and always has! VB6 is still very popular. (And once you learn how to program in one language it is generally easy to export those skills to another language.) People seem to hate vb.NET's reliance on the .NET Framework. It's considered unnecessary bloatware by many. Not me though, I think it's a nice and easy language to get to grips with. Link to comment Share on other sites More sharing options...
Guest Stefkov Posted September 19, 2007 Share Posted September 19, 2007 Private Sub CmdSearchSurname_Click() Dim s As Student Dim StudentChannel As Integer Dim Studentpos As Integer Dim FoundStudent As Boolean FoundStudent = False Studentpos = 1 StudentChannel = FreeFile Open StudentFile For Random As StudentChannel Len = StudentLength Get StudentChannel, Studentpos, s Do While Not EOF(StudentChannel) If Trim(s.Surname) = Trim(TxtSurname.Text) Then LstStudentSurnameSearch.AddItem s.Forename End If Loop If FoundStudent = False Then MsgBox "There are no students with this surname" End If Private Sub CmdSearchSurname_Click() Dim s As Student Dim StudentChannel As Integer Dim studentpos As Integer Dim FoundStudent As Boolean FoundStudent = False studentpos = 1 StudentChannel = FreeFile Open StudentFile For Random As StudentChannel Len = StudentLength Get StudentChannel, studentpos, s Do While Not EOF(StudentChannel) If Trim(s.Surname) = Trim(TxtSurname.Text) Then LstStudentDetails.AddItem Trim(s.Forename) & " (" & s.DateofBirth & ")" LstStudentDetails.ItemData(LstStudentDetails.NewIndex) = studentpos FoundStudent = True End If studentpos = studentpos + 1 Get StudentChannel, studentpos, s Loop If FoundStudent = False Then MsgBox "There are no students with this surname" End If End Sub So its solved? Can you post the code, I'm curious. I ended the first search, but getting one, I didn't get the next details positioned after and checked if that was the same as the searched name. There's the Item data/new index, which is the invisible list box which has the position of the data. (Like it'll have some details then if that was position 21 is would have 21 in the item data) Link to comment Share on other sites More sharing options...
Mr_Odwin Posted September 19, 2007 Share Posted September 19, 2007 If the While Loop hit the last student (so the studentpos+1 puts the index past the actual last), wouldn't the second Get StudentChannel, studentpos, s cause an error? Dunno ... don't really follow the code that well. My experience isn't vast. Oooooh ... could save some cpu cycles by changing Do While Not EOF(StudentChannel) to something like Do While Not EOF(StudentChannel) And Not FoundStudent Link to comment Share on other sites More sharing options...
theguyfromspark Posted September 21, 2007 Share Posted September 21, 2007 VB6 is still very popular. (And once you learn how to program in one language it is generally easy to export those skills to another language.) People seem to hate vb.NET's reliance on the .NET Framework. It's considered unnecessary bloatware by many. Not me though, I think it's a nice and easy language to get to grips with. I've never met anyone that consideres .NET framework to be bloatware but anyway, C# is the way to go, it's better paid, better syntax and makes you a better programmer. Link to comment Share on other sites More sharing options...
Mr_Odwin Posted September 21, 2007 Share Posted September 21, 2007 A google search on ".net framework bloatware" would show that it's a common reasonably opinion. I've written a free application (vb.net not c#) and one of the major causes of concern with most users thinking of installing it is that it requires the framework. I can imagine that c# can be the language of choice for "heavy" programmers, but for people who just do simple things or make GUIs vb.net could be quite adequate. The best language is the one that best meets your needs, and the needs of your users. It probably isn't the same language for everyone. (Forgetting about the paid/job side of things for now.) Link to comment Share on other sites More sharing options...
theguyfromspark Posted September 21, 2007 Share Posted September 21, 2007 Yeah, you're right. Any VB language is good to learn basic programming from, but the jump from VB.NET to C# isn't that huge these days yet the gains are really remarkable so my advice will always be to try and get into C# if your doing VB.NET. Also, most of the framework versions are automatically downloaded via windows update these days anyway and at 60 MB, it's hardly massive for the gain in stability .NET provides. Anyway, this is off topic... I just like talking about programming! Yes, that's a geeky thing to say! Link to comment Share on other sites More sharing options...
Recommended Posts