none
Statement not in a Valid namespace? RRS feed

  • Question

  • Hey guys, im a student and am working on a little project given out by my teacher. its about making a "Horoscope" thing with Visual Basic, sounds easy enough. anyways i went out and googled for a little guide or reference or something for me to use.

    and i found this site as a little guide http://www.visual-basic-tutorials.com/zodiac-sign-tutorial-in-visual-basic.html

    i went and did all the code however visual basic says the "Function Process(dateofbirth As Date) As String" part has something wrong.

    it says the "dateofbirth" part was not in a valid namespace. i understand that the guide may be roughly 3 years old and is probably using outdated pieces of code, but if there is a way to fix this i would be glad to know though.

    if you guys have a different piece of "source code" i can use would be nice to know too tho.

    • Moved by 宝宝徐 Tuesday, October 24, 2017 8:40 AM
    Wednesday, October 18, 2017 2:48 PM

All replies

  • If there is a trustful “Download” link on that page, have you tried to get the files, unarchive, open the solution in Visual Studio and investigate it?

    Wednesday, October 18, 2017 4:52 PM
  • Hi,

    I made a project which was copied from where you provided, and it works perfectly.

    (I found one unnecessary statement, but it does not affect its behavior.)
    Did you copy this?
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
           Dim DOB As Date = DateTimePicker1.Value
           TextBox1.Text = Process(DOB)
    End Sub
    Type of a variable DOB (stands for DateOfBirth) is Date, which comes from DateTimePicker.
    And it is a parameter of function "Process".
    Please check if you have some mistake about Type.

    Regards,

    Ashidacchi

    Wednesday, October 18, 2017 10:49 PM
  • It seems to work no problem at all. and i have no idea how to view the code if i open the solution though.
    Wednesday, October 18, 2017 10:50 PM
  • Hi,

    I made a project which was copied from where you provided, and it works perfectly.

    (I found one unnecessary statement, but it does not affect its behavior.)
    Did you copy this?
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
           Dim DOB As Date = DateTimePicker1.Value
           TextBox1.Text = Process(DOB)
    End Sub
    Type of a variable DOB (stands for DateOfBirth) is Date, which comes from DateTimePicker.
    And it is a parameter of function "Process".
    Please check if you have some mistake about Type.

    Regards,

    Ashidacchi

    Instead of a button click mine is form load.

    and no i did not copy that.

    Wednesday, October 18, 2017 11:34 PM
  • Hi,

    You might define Date of Birth wrong.
    Please provide your code of MyBase.Load.

    Regards,

    Ashidacchi

    Wednesday, October 18, 2017 11:49 PM
  • here

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            DateTimePicker1.Format = DateTimePickerFormat.Short
            Pbox.Image = Nothing
        End Sub
    End Class

    Thursday, October 19, 2017 1:03 AM
  • Hi,

    In your MyBase.Load, nothing exist for substituting [Go] button.
    ' ---[Go] button: Click
    Private Sub btn_Go_Click(sender As System.Object, e As System.EventArgs) Handles btn_Go.Click
    	Dim DOB As Date = DateTimePicker1.Value
    	TextBox1.Text = Process(DOB)
    End Sub
    You should add two statements in your MyBase.Load:
    Dim DOB As Date = DateTimePicker1.Value
    TextBox1.Text = Process(DOB)
    Regards,

    P.S.
    If you do not use a button, you cannot pickup arbitrary date. i.e. it is fixed to Today.


    Ashidacchi


    • Edited by Ashidacchi Thursday, October 19, 2017 1:18 AM
    Thursday, October 19, 2017 1:15 AM
  • Hi,

    I've found a bug in original source code (http://www.visual-basic-tutorials.com/zodiac-sign-tutorial-in-visual-basic.html).

    In Function Zodiac(id as Integer) As String:
    (wrong) PictureBox1.Image =
    (correct) PictureBox1.BackgroundImage = 

    (wrong)
    (correct)

    Code should be like the below. 
    Public Function Zodiac(id As Integer) As String
    	Dim sign As String = ""
    	Dim planet As String = ""
    	Dim charas As String = ""
    	' ---
    	Select Case id
    		Case 1
    			sign = "Aries"
    			PictureBox1.BackgroundImage = My.Resources.Aries
    			planet = "Mars"
    			charas = "Active, Demanding, Determined, Effective, Ambitious"
    		Case 2
    			sign = "Taurus"
    			PictureBox1.BackgroundImage = My.Resources.Taurus
    			planet = "Venus"
    			charas = "Security, Subtle strength, Appreciation, Instruction, Patience"
    ....
    If code is "PictureBox1.Image", zodiac image cannot be shown as a whole. When code is "PictureBox1.BackgroundImage", it can be shown correctly (when PictureBox1.BackgroundImageLayout = Zoom). 

    Regards,

    Ashidacchi


    • Edited by Ashidacchi Thursday, October 19, 2017 1:49 AM
    • Proposed as answer by Fletch Zhou Friday, October 20, 2017 10:00 AM
    Thursday, October 19, 2017 1:43 AM
  • Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            DateTimePicker1.Format = DateTimePickerFormat.Short
            Pbox.Image = Nothing
            Dim DOB As Date = DateTimePicker1.Value
            tbsign.Text = Process(DOB)
        End Sub
    End Class
    
    Private Sub Bgo_Click(sender As System.Object, e As EventArgs) Handles Bgo.Click
        Dim DOB As Date = DateTimePicker1.Value
        tbsign.Text = Process(DOB)
    End Sub
    
    Public Function Process(DOB As Date) As String
        Dim nfo As String
        Dim Bmonth As Integer = DOB.Month
        Dim Bday As Integer = DOB.Day

    I did as you said. im still getting errors. 

    if im being a little hard headed here i apologize xD, im just a student and only just began with Visual Studio a couple of months ago.

    Maybe i should try making my own using what i know so far about Visual Studio.

    Thursday, October 19, 2017 2:07 AM
  • Hi,

    According to my policy, I will not provide code to students, will provide only suggestions.

    Source code provided where you mentioned in your first post has some faults, but it works fine for showing zodiac symbol or text.
    If you are a just learner, please copy the source instead of modifying it.And create a Windows Form as the URL teaches.

    Regards,

    Ashidacchi

    Thursday, October 19, 2017 2:35 AM