|
-
Sep 30th, 2008, 11:57 AM
#1
Thread Starter
Lively Member
-
Sep 30th, 2008, 12:03 PM
#2
Re: [2008] How to send DateTimePicker value to TextBoxes?
I dont use WinRar so cant say (most use winzip).
Is this an ASP.NET webproject?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2008, 12:06 PM
#3
Re: [2008] How to send DateTimePicker value to TextBoxes?
In the button.click event handler, you simply set the text property of the textbox of your choice to display the date. Something like this
Code:
Private Sub Button1_Click(Byval sender as Object, ByVal e As System.EventArgs)....
Me.TextBox1.Text = Me.DateTimePicker1.Value.ToString()
End Sub
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Sep 30th, 2008, 12:08 PM
#4
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by RobDog888
I dont use WinRar so cant say (most use winzip).
Is this an ASP.NET webproject?
it's vb.net form
-
Sep 30th, 2008, 12:09 PM
#5
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by RobDog888
I dont use WinRar so cant say (most use winzip).
Is this an ASP.NET webproject?
Actually, I found WinRar is way better than Winzip. So it's about time to pitch Winzip and get WinRar now, Rob
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Sep 30th, 2008, 12:17 PM
#6
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by stanav
In the button.click event handler, you simply set the text property of the textbox of your choice to display the date. Something like this
Code:
Private Sub Button1_Click(Byval sender as Object, ByVal e As System.EventArgs)....
Me.TextBox1.Text = Me.DateTimePicker1.Value.ToString()
End Sub
Thanks for reply...
The codes working , but i wanted it with comboboxes approach codes ...
-
Sep 30th, 2008, 12:24 PM
#7
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by HOTFIX
Thanks for reply...
The codes working , but i wanted it with comboboxes approach codes ...
What exactly is "comboboxes approach"? Care to explain? I'm not downloading your project just to take a look...
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Sep 30th, 2008, 12:38 PM
#8
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by stanav
What exactly is "comboboxes approach"? Care to explain? I'm not downloading your project just to take a look...
I have include an image to my 1st topic could U PLZ check it .
THANKS
-
Sep 30th, 2008, 12:59 PM
#9
Re: [2008] How to send DateTimePicker value to TextBoxes?
I've looked at the picture and still could not figure out what you mean by saying "comboboxes approach".
If you mean to display the date in a textbox with the same format as it is displayed in the datetimepicker then it's just a matter of supplying the Date.ToString method with the custom format of your choice.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Sep 30th, 2008, 01:13 PM
#10
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by stanav
I've looked at the picture and still could not figure out what you mean by saying "comboboxes approach".
If you mean to display the date in a textbox with the same format as it is displayed in the datetimepicker then it's just a matter of supplying the Date.ToString method with the custom format of your choice.
I mean when I select “A” from combox1 & select “1”from combobox2 the DateTimePicker Value will transfer to correct cell in the table
-
Sep 30th, 2008, 01:29 PM
#11
Re: [2008] How to send DateTimePicker value to TextBoxes?
OK, simplest way to do this is to put all of your textboxes in a 2-d array, then you can refer to them using the array indices.
In your picture, I see that you have 2 columns and 3 rows of textboxes. The 1st combobox indicates the column number and the 2nd combobox gives the row number, is that right?
If that's the case, you simply do this:
Code:
'Declare a class level 2-d textbox array
Private myTextBoxes(,) As TextBox
'Then in the form load event handler, you populate the textbox array
Private Sub Form1_Load(Byval......) Handles MyBase.Load
myTextBoxes = New TextBox(,) {{TextBox1, TextBox3, TextBox5}, {TextBox2, TextBox4, TextBox6}}
End Sub
'And finally in the button click event handler, you do
Dim column As Integer = ComboBox1.SelectedIndex
Dim row As Integer = comboBox2.SelectedIndex
If row > -1 AndAlso column > -1 Then
myTextBoxes(row, column).Text = DateTimePicvker1.Value.ToString()
End If
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Sep 30th, 2008, 04:35 PM
#12
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by stanav
OK, simplest way to do this is to put all of your textboxes in a 2-d array, then you can refer to them using the array indices.
In your picture, I see that you have 2 columns and 3 rows of textboxes. The 1st combobox indicates the column number and the 2nd combobox gives the row number, is that right?
If that's the case, you simply do this:
Code:
'Declare a class level 2-d textbox array
Private myTextBoxes(,) As TextBox
'Then in the form load event handler, you populate the textbox array
Private Sub Form1_Load(Byval......) Handles MyBase.Load
myTextBoxes = New TextBox(,) {{TextBox1, TextBox3, TextBox5}, {TextBox2, TextBox4, TextBox6}}
End Sub
'And finally in the button click event handler, you do
Dim column As Integer = ComboBox1.SelectedIndex
Dim row As Integer = comboBox2.SelectedIndex
If row > -1 AndAlso column > -1 Then
myTextBoxes(row, column).Text = DateTimePicvker1.Value.ToString()
End If
Hi stanav...
I put your suggested code:
Code:
Public Class Form1
Private myTextBoxes(,) As TextBox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim column As Integer = ComboBox1.SelectedIndex
Dim row As Integer = ComboBox2.SelectedIndex
If row > -1 AndAlso column > -1 Then
myTextBoxes(row, column).Text = DateTimePicker1.Value.ToString()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myTextBoxes = New TextBox(,) {{TextBox1, TextBox3, TextBox5}, {TextBox2, TextBox4, TextBox6}}
End Sub
End Class
It working only for Cells A:1 & A:2
The rest cells I get errors and incorrect DateTimePicker values position.
Note:ComboBox1(columns A,B) & ComboBox2(rows 1,2,3)
A:1= TextBox1
A:2= TextBox2
A:3= TextBox3
B:1= TextBox4
B:2= TextBox5
B:3= TextBox6
-
Oct 1st, 2008, 07:25 AM
#13
Re: [2008] How to send DateTimePicker value to TextBoxes?
That means you need to put the TextBoxes to the array in the right order.
Change this line in the Form.Load event handler
Code:
myTextBoxes = New TextBox(,) {{TextBox1, TextBox3, TextBox5}, {TextBox2, TextBox4, TextBox6}}
To this and you should be all set.
Code:
myTextBoxes = New TextBox(,) {{TextBox1, TextBox2, TextBox3}, {TextBox4, TextBox5, TextBox6}}
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Oct 1st, 2008, 11:29 AM
#14
Thread Starter
Lively Member
-
Oct 1st, 2008, 01:24 PM
#15
Re: [2008] How to send DateTimePicker value to TextBoxes?
Hi,
I know it isn't the best way, but it's working:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ComboBox1.SelectedItem = ("A") And ComboBox2.SelectedItem = ("1") Then TextBox1.Text = DateTimePicker1.Value.ToString End If If ComboBox1.SelectedItem = ("A") And ComboBox2.SelectedItem = ("2") Then TextBox2.Text = DateTimePicker1.Value.ToString End If If ComboBox1.SelectedItem = ("A") And ComboBox2.SelectedItem = ("3") Then TextBox3.Text = DateTimePicker1.Value.ToString End If If ComboBox1.SelectedItem = ("B") And ComboBox2.SelectedItem = ("4") Then TextBox4.Text = DateTimePicker1.Value.ToString End If If ComboBox1.SelectedItem = ("B") And ComboBox2.SelectedItem = ("5") Then TextBox5.Text = DateTimePicker1.Value.ToString End If If ComboBox1.SelectedItem = ("B") And ComboBox2.SelectedItem = ("6") Then TextBox6.Text = DateTimePicker1.Value.ToString End If End Sub
Hope it helps,
sparrow1
-
Oct 1st, 2008, 01:51 PM
#16
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by HOTFIX
Thanks for reply...
I still have same problems of errors and incorrect positions...
Any idea.. 
What errors? What incorrect positions? Saying that your program is having errors without providing what the errors are is not a way to start trouble shooting/debugging.
Besides, the code I gave you should give you enough that you can see the logic to achieve what you need. You should be able to adjust it so that it works the way you want. Don't just copy sample code into your program and expect it to work as is...
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Oct 1st, 2008, 03:36 PM
#17
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by sparrow1
Hi,
I know it isn't the best way, but it's working:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.SelectedItem = ("A") And ComboBox2.SelectedItem = ("1") Then
TextBox1.Text = DateTimePicker1.Value.ToString
End If
If ComboBox1.SelectedItem = ("A") And ComboBox2.SelectedItem = ("2") Then
TextBox2.Text = DateTimePicker1.Value.ToString
End If
If ComboBox1.SelectedItem = ("A") And ComboBox2.SelectedItem = ("3") Then
TextBox3.Text = DateTimePicker1.Value.ToString
End If
If ComboBox1.SelectedItem = ("B") And ComboBox2.SelectedItem = ("4") Then
TextBox4.Text = DateTimePicker1.Value.ToString
End If
If ComboBox1.SelectedItem = ("B") And ComboBox2.SelectedItem = ("5") Then
TextBox5.Text = DateTimePicker1.Value.ToString
End If
If ComboBox1.SelectedItem = ("B") And ComboBox2.SelectedItem = ("6") Then
TextBox6.Text = DateTimePicker1.Value.ToString
End If
End Sub
Hope it helps,
sparrow1
Many Thanks "sparrow1" this way of codes is working great, although there are many lines...
Regrads...
-
Oct 1st, 2008, 03:50 PM
#18
Re: [2008] How to send DateTimePicker value to TextBoxes?
sparrow's code could have been shorter with select case
Code:
Select Case ComboBox1.SelectedItem.ToString & ComboBox2.SelectedItem.ToString
Case "A1"
Case "A2"
End Select
-
Oct 1st, 2008, 04:10 PM
#19
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by stanav
What errors? What incorrect positions? Saying that your program is having errors without providing what the errors are is not a way to start trouble shooting/debugging.
Besides, the code I gave you should give you enough that you can see the logic to achieve what you need. You should be able to adjust it so that it works the way you want. Don't just copy sample code into your program and expect it to work as is...
Hi stanav..
Sorry for not giving enough details about the errors because I assumed you have run the application on your pc and having same errors…
I really try to work logically how the codes are working that why I give you the note of textbox locations in the table “A:1=Textbox1,A:2=Textbox2…etc” because I have tried swapping the Textboxes in line coding “{{TextBox1, TextBox2, TextBox3}, {TextBox4, TextBox5, TextBox6}}”
And I even tried to change numeric value in code line “If row > -1 AndAlso column > -1 Then”.
Please note: my level in VB.NET is beginner and the English language is not my first language so please excuse me.
Anyway I appreciate your help …
Best Regards…
Last edited by HOTFIX; Oct 1st, 2008 at 04:47 PM.
-
Oct 2nd, 2008, 02:58 AM
#20
Thread Starter
Lively Member
Re: [2008] How to send DateTimePicker value to TextBoxes?
 Originally Posted by dbasnett
sparrow's code could have been shorter with select case
Code:
Select Case ComboBox1.SelectedItem.ToString & ComboBox2.SelectedItem.ToString
Case "A1"
Case "A2"
End Select
Hi dbasnett …
Thanks for advice; I’ll try to use this method...
Regards…
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|