Formating Dates

Formating dates from a file...

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

43 Replies - 3153 Views - Last Post: 30 July 2008 - 12:30 AM Rate Topic: -----

#31 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 09:59 PM

View PostLadyWolf, on 30 Jul, 2008 - 12:42 AM, said:

View PostLadyWolf, on 30 Jul, 2008 - 12:35 AM, said:

View PostAdamSpeight2008, on 30 Jul, 2008 - 12:34 AM, said:

View PostLadyWolf, on 30 Jul, 2008 - 05:13 AM, said:

View PostAdamSpeight2008, on 29 Jul, 2008 - 10:59 PM, said:

Figured it out :^:
first Make sure that xDatesLabel is ReadOnly and has vertical scrollbars.
Remove the listbox.
Then any lines that contain references to the listbox. (the ones with the errors)

Add this event code
    Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles xDatesLabel.MouseClick
        Dim line As Integer = -1
        If e.Button = Windows.Forms.MouseButtons.Left Then
' Find out which text line the mouse click was on.
            line = Me.xDatesLabel.GetLineFromCharIndex(Me.xDatesLabel.GetCharIndexFromPosition(e.Location))
         End If
        If line <> -1 Then
' Display lotto numbers
            Me.xLbl_Lotto.Text = _
            Lottos(line).Number(0) & " " & _
            Lottos(line).Number(1) & " " & _
            Lottos(line).Number(2) & " " & _
            Lottos(line).Number(3) & " " & _
            Lottos(line).Number(4)

        End If
    End Sub


And cha-ching!(VB.Net :ph34r: )


mmmmmmm Never made a Label 'Read Only' and didn't know scrollbars could be added to a label. I'm looking to find, but don't see where their at.

The control named xDatesLabel is actually a Textbox.


Ahhh okay...


Okay text box is up..


How do I make the text box 'Read Only'?
Was This Post Helpful? 0
  • +
  • -

#32 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Formating Dates

Posted 29 July 2008 - 10:08 PM

View PostLadyWolf, on 30 Jul, 2008 - 05:59 AM, said:

How do I make the text box 'Read Only'?

In the form designer, left click on the textbox
Properties
behavior->Read Only
or
Read Only

Set to True
Was This Post Helpful? 0
  • +
  • -

#33 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 10:19 PM

View PostAdamSpeight2008, on 30 Jul, 2008 - 01:08 AM, said:

View PostLadyWolf, on 30 Jul, 2008 - 05:59 AM, said:

How do I make the text box 'Read Only'?

In the form designer, left click on the textbox
Properties
behavior->Read Only
or
Read Only

Set to True


Ahhh Okay!! Learned something new!! Thanks!
Was This Post Helpful? 0
  • +
  • -

#34 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 10:25 PM

mmmmmm I started application, and nothing shows in the xDatesLabel, and Dates are showing in the xLbl_Lotto... Here's the code..There are no errors though.


Option Explicit On
Option Strict On

Public Class MainForm

	Dim Lottos As New List(Of Lotto)

	Private Structure Lotto
		Public Datum As String
		Public Number() As Integer
	End Structure

	' csv file Format  
	' Date , Number 1, Number 2,Number 3, Number 4, Number 5

	Private Sub xDisplayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xDisplayButton.Click
		' Prepare file to be parsed			
		Dim Delimiters() As Char = {CChar(",")}
		Dim tfp As Microsoft.VisualBasic.FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser("fantasyfive.txt", Delimiters)
		' List to contain read in lottos	
		Dim NewLotto As Lotto
		' Define stringBuild to speed up the building of the string.  
		Dim listText As New System.Text.StringBuilder
		Dim Fields() As String
		While (tfp.EndOfData = False)
			NewLotto = New Lotto
			Fields = tfp.ReadFields
			' The Fields array now contains the following data	
			' Fields(0) => The Day	
			' Fields(1) => The Date  
			' Fields(2) => Number 1	
			' Fields(3) => Number 2	
			' Fields(4) => Number 3	
			' Fields(5) => Number 4	
			' Fields(6) => Number 5	

			NewLotto.Datum = CDate(Fields(1)).ToString("MM dd yy")
			ReDim NewLotto.Number(4)
			For i As Integer = 1 To 5
				NewLotto.Number(i - 1) = CInt(Fields(i + 1))
			Next

			' Sort the number	
			Array.Sort(NewLotto.Number)
			' Add it to the collection of other lottos	
			Lottos.Add(NewLotto)
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum)

		End While
		Me.xLbl_Lotto.Text = listText.ToString
		tfp.Close()
	End Sub

	Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
		Dim line As Integer = -1
		If e.Button = Windows.Forms.MouseButtons.Left Then
			'find out which text line the mouse click was on.  
			line = Me.xDatesLabel.GetLineFromCharIndex(Me.xDatesLabel.GetCharIndexFromPosition(e.Location))
		End If
		If line <> -1 Then
			'splay lotto numbers  
			Me.xLbl_Lotto.Text = _
			Lottos(line).Number(0) & " " & _
			Lottos(line).Number(1) & " " & _
			Lottos(line).Number(2) & " " & _
			Lottos(line).Number(3) & " " & _
			Lottos(line).Number(4)

		End If
	End Sub

	Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
		Me.Close()

	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#35 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Formating Dates

Posted 29 July 2008 - 10:30 PM

View PostLadyWolf, on 30 Jul, 2008 - 06:25 AM, said:

mmmmmm I started application, and nothing shows in the xDatesLabel, and Dates are showing in the xLbl_Lotto... Here's the code..There are no errors though.


Option Explicit On
Option Strict On

Public Class MainForm

	Dim Lottos As New List(Of Lotto)

	Private Structure Lotto
		Public Datum As String
		Public Number() As Integer
	End Structure

	' csv file Format  
	' Date , Number 1, Number 2,Number 3, Number 4, Number 5

	Private Sub xDisplayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xDisplayButton.Click
		' Prepare file to be parsed			
		Dim Delimiters() As Char = {CChar(",")}
		Dim tfp As Microsoft.VisualBasic.FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser("fantasyfive.txt", Delimiters)
		' List to contain read in lottos	
		Dim NewLotto As Lotto
		' Define stringBuild to speed up the building of the string.  
		Dim listText As New System.Text.StringBuilder
		Dim Fields() As String
		While (tfp.EndOfData = False)
			NewLotto = New Lotto
			Fields = tfp.ReadFields
			' The Fields array now contains the following data	
			' Fields(0) => The Day	
			' Fields(1) => The Date  
			' Fields(2) => Number 1	
			' Fields(3) => Number 2	
			' Fields(4) => Number 3	
			' Fields(5) => Number 4	
			' Fields(6) => Number 5	

			NewLotto.Datum = CDate(Fields(1)).ToString("MM dd yy")
			ReDim NewLotto.Number(4)
			For i As Integer = 1 To 5
				NewLotto.Number(i - 1) = CInt(Fields(i + 1))
			Next

			' Sort the number	
			Array.Sort(NewLotto.Number)
			' Add it to the collection of other lottos	
			Lottos.Add(NewLotto)
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum)

		End While
		Me.xDatesLabel.Text = listText.ToString '<-wrong control
		tfp.Close()
	End Sub

	Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
		Dim line As Integer = -1
		If e.Button = Windows.Forms.MouseButtons.Left Then
			'find out which text line the mouse click was on.  
			line = Me.xDatesLabel.GetLineFromCharIndex(Me.xDatesLabel.GetCharIndexFromPosition(e.Location))
		End If
		If line <> -1 Then
			'splay lotto numbers  
			Me.xLbl_Lotto.Text = _
			Lottos(line).Number(0) & " " & _
			Lottos(line).Number(1) & " " & _
			Lottos(line).Number(2) & " " & _
			Lottos(line).Number(3) & " " & _
			Lottos(line).Number(4)

		End If
	End Sub

	Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
		Me.Close()

	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#36 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 10:50 PM

Dates are where their suppose to be, but not right, and no numbers in xLbl_Lotto. Here's code again and screen shot.


Option Explicit On
Option Strict On

Public Class MainForm

	Dim Lottos As New List(Of Lotto)

	Private Structure Lotto
		Public Datum As String
		Public Number() As Integer
	End Structure

	' csv file Format  
	' Date , Number 1, Number 2,Number 3, Number 4, Number 5

	Private Sub xDisplayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xDisplayButton.Click
		' Prepare file to be parsed			
		Dim Delimiters() As Char = {CChar(",")}
		Dim tfp As Microsoft.VisualBasic.FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser("fantasyfive.txt", Delimiters)
		' List to contain read in lottos	
		Dim NewLotto As Lotto
		' Define stringBuild to speed up the building of the string.  
		Dim listText As New System.Text.StringBuilder
		Dim Fields() As String
		While (tfp.EndOfData = False)
			NewLotto = New Lotto
			Fields = tfp.ReadFields
			' The Fields array now contains the following data	
			' Fields(0) => The Day	
			' Fields(1) => The Date  
			' Fields(2) => Number 1	
			' Fields(3) => Number 2	
			' Fields(4) => Number 3	
			' Fields(5) => Number 4	
			' Fields(6) => Number 5	

			NewLotto.Datum = CDate(Fields(1)).ToString("MM dd yy")
			ReDim NewLotto.Number(4)
			For i As Integer = 1 To 5
				NewLotto.Number(i - 1) = CInt(Fields(i + 1))
			Next

			' Sort the number	
			Array.Sort(NewLotto.Number)
			' Add it to the collection of other lottos	
			Lottos.Add(NewLotto)
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum)

		End While
		Me.xDatesLabel.Text = listText.ToString
		tfp.Close()
	End Sub

	Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
		Dim line As Integer = -1
		If e.Button = Windows.Forms.MouseButtons.Left Then
			'find out which text line the mouse click was on.  
			line = Me.xDatesLabel.GetLineFromCharIndex(Me.xDatesLabel.GetCharIndexFromPosition(e.Location))
		End If
		If line <> -1 Then
			'splay lotto numbers  
			Me.xLbl_Lotto.Text = _
			Lottos(line).Number(0) & " " & _
			Lottos(line).Number(1) & " " & _
			Lottos(line).Number(2) & " " & _
			Lottos(line).Number(3) & " " & _
			Lottos(line).Number(4)

		End If
	End Sub

	Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
		Me.Close()

	End Sub
End Class

Attached File(s)

  • Attached File  Doc3.doc (117K)
    Number of downloads: 54

Was This Post Helpful? 0
  • +
  • -

#37 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Formating Dates

Posted 29 July 2008 - 11:02 PM

Looks like the textbox hasn't got multi-line enabled.
It under the same heading as ReadOnly.

What font is it using?
Was This Post Helpful? 0
  • +
  • -

#38 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 11:10 PM

View PostAdamSpeight2008, on 30 Jul, 2008 - 02:02 AM, said:

Looks like the textbox hasn't got multi-line enabled.
It under the same heading as ReadOnly.

What font is it using?


Font is Microsoft Sans Serif

View PostLadyWolf, on 30 Jul, 2008 - 02:07 AM, said:

View PostAdamSpeight2008, on 30 Jul, 2008 - 02:02 AM, said:

Looks like the textbox hasn't got multi-line enabled.
It under the same heading as ReadOnly.

What font is it using?


Font is Microsoft Sans Serif


yay! Figured the multi-line part out, and dates are fine, but can't click on dates, to display numbers in the xLbl_Lotto.

This post has been edited by LadyWolf: 29 July 2008 - 11:15 PM

Was This Post Helpful? 0
  • +
  • -

#39 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Formating Dates

Posted 29 July 2008 - 11:18 PM

Spotted the cause
Change this
   Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) 

to this
   Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles xDatesLabel.MouseClick
 


Fingers crossed
Was This Post Helpful? 1
  • +
  • -

#40 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 11:22 PM

View PostAdamSpeight2008, on 30 Jul, 2008 - 02:18 AM, said:

Spotted the cause
Change this
   Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) 

to this
   Private Sub xDatesLabel_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles xDatesLabel.MouseClick
 


Fingers crossed

:^: :D Thanks sweety! Your awesome! :wub:

This post has been edited by LadyWolf: 29 July 2008 - 11:24 PM

Was This Post Helpful? 0
  • +
  • -

#41 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 29 July 2008 - 11:57 PM

I'm curious though, what does this part do within the code?


' Sort the number	
			Array.Sort(NewLotto.Number)
			' Add to collection of other lottos	
			Lottos.Add(NewLotto)
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum)


Was This Post Helpful? 0
  • +
  • -

#42 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Formating Dates

Posted 30 July 2008 - 12:03 AM

View PostLadyWolf, on 30 Jul, 2008 - 07:57 AM, said:

I'm curious though, what does this part do within the code?


' Sort the number	
			Array.Sort(NewLotto.Number) '<- Didn't if the numbers where in numerical order
			' Add to collection of other lottos	
			Lottos.Add(NewLotto) 
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum) 'Add the datum of the last added Lotto, to the list which will become the date list.
'Speeds the building the list. If we add the to the text directly using
' xDatesLabel.text &= Lottos(Lottos.Count - 1).Datum
' would take ages.


This post has been edited by AdamSpeight2008: 30 July 2008 - 12:07 AM

Was This Post Helpful? 0
  • +
  • -

#43 LadyWolf  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 25-June 08

Re: Formating Dates

Posted 30 July 2008 - 12:18 AM

View PostAdamSpeight2008, on 30 Jul, 2008 - 03:03 AM, said:

View PostLadyWolf, on 30 Jul, 2008 - 07:57 AM, said:

I'm curious though, what does this part do within the code?


' Sort the number	
			Array.Sort(NewLotto.Number) '<- Didn't if the numbers where in numerical order
			' Add to collection of other lottos	
			Lottos.Add(NewLotto) 
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum) 'Add the datum of the last added Lotto, to the list which will become the date list.
'Speeds the building the list. If we add the to the text directly using
' xDatesLabel.text &= Lottos(Lottos.Count - 1).Datum
' would take ages.



ahhh okay :) Learned a few new things today! Thank-you!
Was This Post Helpful? 0
  • +
  • -

#44 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Formating Dates

Posted 30 July 2008 - 12:30 AM

View PostLadyWolf, on 30 Jul, 2008 - 08:18 AM, said:

View PostAdamSpeight2008, on 30 Jul, 2008 - 03:03 AM, said:

View PostLadyWolf, on 30 Jul, 2008 - 07:57 AM, said:

I'm curious though, what does this part do within the code?


' Sort the number	
			Array.Sort(NewLotto.Number) '<- Didn't if the numbers where in numerical order
			' Add to collection of other lottos	
			Lottos.Add(NewLotto) 
			listText.AppendLine(Lottos(Lottos.Count - 1).Datum) 'Add the datum of the last added Lotto, to the list which will become the date list.
'Speeds the building the list. If we add the to the text directly using
' xDatesLabel.text &= Lottos(Lottos.Count - 1).Datum
' would take ages.



ahhh okay :) Learned a few new things today! Thank-you!

Today has been a good day but I need sleep. :zzz:
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3