message box to show up?

NoobConfoobed

Member
Joined
Jul 12, 2012
Messages
5
Programming Experience
Beginner
OK,

I am BRAND NEW to VB.NET, so please bare with me. I am trying to get the message box to show up with the answer. The answer will be (for now, once I work out how to do this, I will integrate the appropriate sums). Textbox = 40

Where am I going wrong here. I realize that my Cat should be able to do this:

VB.NET:
Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim Number As Integer
        Dim Answer As Integer




        Number = TextBox1.Text
        Answer = Number + 40


        MessageBox = Answer

Thanks for your patience.
 
Last edited:
OK,

I am BRAND NEW to VB.NET, so please bare with me. I am trying to get the message box to show up with the answer. The answer will be (for now, once I work out how to do this, I will integrate the appropriate sums). Textbox = 40

Where am I going wrong here. I realize that my Cat should be able to do this:

VB.NET:
Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim Number As Integer
        Dim Answer As Integer




        Number = TextBox1.Text
        Answer = Number + 40


        MessageBox = Answer

Thanks for your patience.

Sorry, I meant textbox + 40 at the top. Not =
 
Nothing wrong with being new to programming. Here's a couple of tips for you, when you're stuck on something and want to create a thread asking how to fix something with your code or whatever, the first thing you should always do is tell us exactly what it is you're trying to do & where something isn't working, plus post any relevant code (which you've done in this thread already :) ).

So, what exactly is it you're trying to do here?
I see you're getting a numeric value from a textbox and it looks like you're attempting to show that in a message box with "40" added to the number.

I would suggest you look up some examples on how to show things in message boxes (a google search results in thousands of examples).
Additionally you can always check the MSDN document for the MessageBox class: MessageBox Class (System.Windows.Forms)
 
Nothing wrong with being new to programming. Here's a couple of tips for you, when you're stuck on something and want to create a thread asking how to fix something with your code or whatever, the first thing you should always do is tell us exactly what it is you're trying to do & where something isn't working, plus post any relevant code (which you've done in this thread already :) ).

So, what exactly is it you're trying to do here?
I see you're getting a numeric value from a textbox and it looks like you're attempting to show that in a message box with "40" added to the number.

I would suggest you look up some examples on how to show things in message boxes (a google search results in thousands of examples).
Additionally you can always check the MSDN document for the MessageBox class: MessageBox Class (System.Windows.Forms)

Thanks for your reply Juggalo.

I was just doing this to test if I was on the right tracks. I have changed the code around, it is now much simpler:

VB.NET:
Public Class Form1


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load




    End Sub




    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Answer As Integer


        Answer = TextBox1.Text + 40


        MsgBox(Answer)


    End Sub
End Class

My ultimate goal is to make a Baby Due date calculator (my Fiance is pregnant). I will be using this formula:

Date of last period + 40 weeks = Answer

I now realize this will be a LOT harder than I first imagined. I am not looking to be spoon-fed but a little advice and a point in the right direction would be fantastic.
 
I highly suggest that you use MessageBox.Show() instead of MsgBox(), but at least you did get it to work.

As for how you'd go about making a baby due date, you might want to do some google searches on that topic to get ideas for how that stuff is calculated. I'm not familiar with how doctor's figure that stuff out.

I would suggest that you see about having the program be able to save the data as you enter it into an xml file or something, so you would be able to run the program, open your file and it would bring in all of the data for you, so you dont have to re-enter things.
 
I highly suggest that you use MessageBox.Show() instead of MsgBox(), but at least you did get it to work.

As for how you'd go about making a baby due date, you might want to do some google searches on that topic to get ideas for how that stuff is calculated. I'm not familiar with how doctor's figure that stuff out.

I would suggest that you see about having the program be able to save the data as you enter it into an xml file or something, so you would be able to run the program, open your file and it would bring in all of the data for you, so you dont have to re-enter things.

Hey man,

The date is calculated by last menstrual cycle and then they add 40 weeks. I would like users to be able to enter it in the 'DD/MM/YYYY' format, and then for VB to add 40 weeks onto given date.

Thanks again for your time, and your advice.
 
Create a form.
Toss a DateTimePicker control on it and name that LastMenstrualDatePicker.
Toss a Label control on the form and name it DueDateLabel.
Double click the DateTimePicker, the IDE will create an event handler for the ValueChanged event.
Change the code to this:
Private Sub LastMenstrualDatePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles LastMenstrualDatePicker.ValueChanged
    DueDateLabel.Text = "Estimated delivery date: " & LastMenstrualDatePicker.Value.AddMonths(10).ToShortDateString()
' 40 weeks / 4 weeks per month = 10 months
End Sub
 
I think it will come as a bit of a shock to medicine to discover that it's 10 months - we haven't used a lunar calendar in a looooooooooooong time! And I'd be careful of being too specific, the usual range is 260 to 290 days with 280 days (40 weeks) tending towards the late end of the scale. If you want to be prepared in time I'd tend toward being too early!
 
Back
Top