I know there have been posts in the past where some were asking about "how to make a zodiac calculator," and I kind of have the same question, but I've done the research and wrote most of the code out, so it's nothing like that. I didn't quite understand how to post the code, so I'm just going to give a quick description.
I know the basic codes that I need to insert, but I'm creating it in a windows application. The day and year are text boxes that the user can input that particular information, but the month is a drop-down box.

My two questions are: Is it okay to delete the private sub of the day and year so I can combine them into one sub?

And how do I get the months to show up individually in the code area? Or would I have to delete the drop-down box completely and make it like the day and year text boxes where the user can input the information themselves?

Thanks in advance!

Recommended Answers

All 6 Replies

Code tags are you friend for posting code. :)

1. What private sub for the textboxes, exactly? A .TextChanged event, or what?

2. I'm assuming you've loaded your combobox with the 12 months in design view (under the Items property). If so, it's easy to access the individual items programmatically.

'Assuming your combobox is named cboMonth
dim strMonth as String 
strMonth = cboMonth.Items(0) 'This would be January
strMonth = cboMont.Items(11) 'This would be December
End Sub
    Private Sub txtDayC_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDayC.TextChanged
        
Dim day As Integer
        day = txtDayC.Text


    Private Sub txtYearC_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtYearC.TextChanged

        Dim year As Integer
        year = txtYearC.Text

    End Sub

Ooh, I see. But yes, it's basically a question of is it okay to combine these two subs to make

End Sub
    Private Sub txtDayC_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDayC.TextChanged
        
Dim day, year As Integer
        day = txtDayC.Text
        year = textYearC.Text

    End Sub

I have to write this code for five different calculators, one of which is the Myanmar-Burmese version, so I was wondering if combing subs like this would be okay, or do they have to stay independent?

If you do combine them, I'd make the Sub handle both events.

Private Sub DayYearTextChanged(Byval sender as system.object, byval e as system.eventargs) Handles txtDayC.Textchanged, txtYearC.TextChanged

Dim iDay, iYear as Integer
iDay = txtDayC.Text
iYear = txtYearC.Text

End Sub

That way, you'll get the data regardless of what textbox they modify.


...Though in all reality a DateTimePicker seems far simpler for getting a specific date from your users :P

Awesome, thank you! :)
... a date time picker? ._.;

I don't see why not :)

Be sure to mark the thread as solved, btw.

I didn't know something like that existed.
Thanks a lot though, I really appreciate the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.