|
Did you try something? Where are you stuck up ?
|
|
|
|
|
Isn't this a case of converting the numbers of the year, month and day to base 36?
Try here.[^]
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I am currently trying to make a program that will read in a text file full of records and then allow the user to add or edit
the data. Basically like a database. Well i am trying to set up my queries right now, I am just trying to Sort by Last name and then display all the records in ascending order. the data is passed into 4 different text boxes though, one for FIRST NAME, LAST NAME, PHONE NUMBER, and GPA, SO when the user clicks a NEXT button he/she can view each record sorted by LAST NAME.
My problem i am having though is that when the user clicks the SORT by LAST NAME button it does sort but SPITS OUT THE LAST RECORD of the LIST instead of one at a time and then when he/she tries to click the NEXT BUTTON it just goes to End of File instead of showing the correct sorted list one at a time. CAN SOMEONE PLEASE TELL ME WHAT I AM LEAVING OUT OR NOT DOING RIGHT?
here is my sort routine:
Public Sub btnDisplaySorted_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplaySorted.Click
Dim sortedLastName = From names In students Order By names.lastName Ascending Select names
For Each element In sortedLastName
txtFirstName.Text = element.firstName
txtLastName.Text = element.lastName
txtG.Text = element.gpa
txtPhone.Text = element.tele
Next
End Sub
and my Next button routine:
Public Structure student 'structure used to hold fields in student list
Dim lastName As String
Dim firstName As String
Dim tele As String
Dim gpa As Decimal
End Structure
'GLOBAL Variables needed for entire program
Public students As New List(Of student) 'create list of students
Public oneStudent As New student 'creates a place holder for one selected student
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Dim i As Integer
For i = 0 To students.Count - 1
Dim fname As String = students(i).firstName
Dim lname As String = students(i).lastName
txtFirstName.Text = fname
txtLastName.Text = lname
txtG.Text = oneStudent.gpa
txtPhone.Text = oneStudent.tele
Next i
End Sub
|
|
|
|
|
As far as i can tell you seem to be going about this the wrong way. Once you have read the textfile and parsed
the text into student objects, add each student to the list. To sort the list you have 2 options
1. Implement IComparer in your student structure like so :
Private Structure Student
Implements IComparable
Public lastName As String
Public firstName As String
Public tele As String
Public gpa As Decimal
Public Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo
If TypeOf obj Is Student Then
Dim otherStudent As Student = DirectCast(obj, Student)
Return Me.lastName.CompareTo(otherStudent.lastName)
Else
Throw New ArgumentException("object is not a student")
End If
End Function
End Structure
then once you have assmebled the list of students you can just call
Students.Sort()
and your list will automatically be sorted.
2. If you have to use LinQ (I take it this is homework) then you need to implement a function that returns a sorted list of students like so :
Private Function SortWithLinQ(ByVal StudentList As List(Of Student)) As List(Of Student)
Dim newStudentList As New List(Of Student)
Dim sortedLastName = From names In StudentList Order By names.lastName Ascending
For Each element In sortedLastName
newStudentList.Add(element)
Next
Return newStudentList
End Function
and then once you have assembled your list you call
Students = SortWithLinQ(Students)
and then you can implement the logic to scroll through the students.
Hope this helps.
|
|
|
|
|
zimvbcoder, THanks for your help the sort function worked perfectly!
I am still not to sure on the next click event though.
I was trying this:
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Dim i As Integer
For i = 0 To students.Count - 1
Dim lname As String = students(i).lastName
txtLastName.Text = lname
Next i
End Sub
I am currently just passing the new last name to the text box after the user clicks next to see if it will indeed go to
the next record that has been SORTED already and display the last name. But i realized that the variable lname will overwrite
the data being passed to it until it reaches end of file so It always only displays the lastname of the Sorted list. I know that each index would have to passed but i can't just do something like students(0).lastname and then send it out the the textbox because the user can add to the file and so I wouldn't be able to determine how long the list is. What would I need to do?
|
|
|
|
|
You need to declare 3 class variables in your form class.
private currentStudent as student
private intCurrentRecord as integer
private intRecordcount as integer
While loading the records you need to increment intRecordcount for each record.
When finished loading the student records set intCurrentRecord to 0.
You then need to declare a function to set the records i.e.
Private Sub SetRecord()
If intRecordCount >= 0 Then
currentStudent = Students(intCurrentRecord)
txtFirstName.Text = currentStudent.firstName
txtLastName.Text = currentStudent.lastName
txtTele.Text = currentStudent.tele
txtGPA.Text = currentStudent.gpa
End If
End Sub
After setting intCurrentRecord call SetRecord which will give you the first student
loaded into the text boxes.
Ideally, instead of just a next button for scrolling through the records, you should
have 4 buttons, i.e Next, Previous, First, and Last buttons.
In each of these button events, increase or decrease intCurrentRecord as appropriate,
and then call SetRecord. i.e.
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If intCurrentRecord < intRecordCount - 1 Then
intCurrentRecord += 1
SetRecord()
End If
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
If intCurrentRecord > 0 Then
intCurrentRecord -= 1
SetRecord()
End If
End Sub
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
intCurrentRecord = 0
SetRecord()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
intCurrentRecord = intRecordCount - 1
SetRecord()
End Sub
Hope this helps
|
|
|
|
|
zimvbcoder, Thanks for all your HELP!!! I appreciate all ur help and time.
|
|
|
|
|
|
Hello to all,
Actually i m selecting the Font of Monotype Corsiva with the Style of Reguler. but after selecting it works for Italic.
Code is Given below. Valuefont is Fontdialog box .
If valuefont.ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Sub
font1 = New Font(valuefont.Font.Name, valuefont.Font.Size, valuefont.Font.Style)
Try to get the answer. why.
If you can think then I Can.
|
|
|
|
|
What are the values of those 3 variables you're passing in to the Font constructor? What does the code look like that's defining those variables and values?
|
|
|
|
|
Check the code which is give above. In Which Valuefont is dialogbox. And the value is passed from Dialog Box. The Error is generating while we select Morovia Corica and Select Style Regular.
If you can think then I Can.
|
|
|
|
|
That doesn't answer the question. Have you VERIFIED what those values are?
|
|
|
|
|
You Can Check For
Try
{
Dim Font1 as Font = New Font (Monotype Corsiva,12,Regular)
}
Catch
{
}
If you can think then I Can.
|
|
|
|
|
|
Why would you need a "SOAP interface" to store data in a database? There's something you're not saying about your concept that needs to be explained for this to make any sense. I mean, a login screen just takes a username and password. It's simple to lookup a username and compare the password enter to the one stored, wihtout using SOAP at all.
|
|
|
|
|
It's not a login screen on a website. I am creating a touch screen to login to when you enter an office.
|
|
|
|
|
So what? That doesn't change anything. All those questions still stand.
|
|
|
|
|
I am creating a screen where one will enter their name and phone number. I want this info to go into the database.
|
|
|
|
|
For the last time...What do you think a "SOAP Interface" is and why do you think you need it??
|
|
|
|
|
When you say a "SOAP interface" presumably you mean a web service?
The answer is, as always, "it depends..." What sort of database are you using? You can expose database functionality for Oracle and SQL Server as a web service and call it directly, but I don't think you can do that with MySQL (for example) so in that case you will need something else in the mix to handle the web service layer.
|
|
|
|
|
Hi!
Any one to help me giving the vb.net code for automated mobile message reading system connected with com port
|
|
|
|
|
Noone is just going to hand you code. You actually have to write it yourself and if you get stuck with a specific problem, we'll help you solve it. If you've just come here to get code, you've come to the wrong site.
|
|
|
|
|
ok i know What was the mistake thanks for your time anyway.
I found a good tutorial in youtube (I dont mean that your tutorial is bad)
i just thought that Youtube will be the last thing i can find what i am seeking for.
It all was my mistake so should i delete this Message"It's ok if you delete it for me i dont needit"?
This is the code i used it worked anyway(FINALLY):
i had to do a class to make this work
Public Class AppConfigReader
Private Shared SettingsReader As New System.Configuration.AppSettingsReader
Private Shared spamTXT_ As String = SettingsReader.GetValue("spamTXT", GetType(String))
Private Shared PNtext_ As String = SettingsReader.GetValue("PNtext", GetType(String))
Private Shared Itext_ As String = SettingsReader.GetValue("Itext", GetType(Byte))
Private Shared EF_ As String = SettingsReader.GetValue("EF", GetType(Byte))
Private Shared HS_ As String = SettingsReader.GetValue("HS", GetType(Byte))
Public Shared ReadOnly Property spamTXT() As String
Get
Return spamTXT_
End Get
End Property
Public Shared ReadOnly Property PNtext() As String
Get
Return PNtext_
End Get
End Property
Public Shared ReadOnly Property Itext() As Byte
Get
Return Itext_
End Get
End Property
Public Shared ReadOnly Property EF() As Byte
Get
Return EF_
End Get
End Property
Public Shared ReadOnly Property HS() As Byte
Get
Return HS_
End Get
End Property
End Class
the config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings >
<add key ="SpamTXT" value ="000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"/>
<add key ="PNtext" value ="Warcraft III"/>
<add key ="Itext" value ="50"/>
<add key ="EF" value ="1"/>
<add key ="HS" value ="1"/>
</appSettings>
</configuration>
i could use all the value in my program like this :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SpamedTXT.Text = AppConfigReader.spamTXT
PNtxt.Text = AppConfigReader.PNtext
Itxt.Text = AppConfigReader.Itext
EF.CheckState = AppConfigReader.EF
HS.CheckState = AppConfigReader.HS
End Sub
this code was for a spammer that i made 2 days ago i am making a program that can remap and stuff like that
Joseph.
modified on Thursday, November 26, 2009 5:40 AM
|
|
|
|
|
Well there is probably a lot of articles on this on CodeProject. So I do not think saying "your tutorial" is going to help in the slightest as "your" could be anyone.
|
|
|
|
|
Articles are supported by the people who wrote them. There is a forum at the bottom of each article where you can post questions about it.
If what you posted is accurate, then you've named the App.Config file incorrectly. It is not App.Code, it's App.Config.
What article are you talking about?
Also, the key "Vault" is not part of the Configuration section schema, so it's not going to work at the level you're showing in your post.
After-Darkness wrote: AssAssin-AOK@hotmail.com
Noone cares about your email address except spammers. Posting your email address will only get you tons and tons of spam in your mailbox.
|
|
|
|