none
My is showing red squeegly line am i missing a Imports statement and references RRS feed

  • Question

  • Hello

    I am specifying the code attached but it is giving compile time error please help asap

    My.Computer.Audio.Play("F:\00001\00001 VB\MyComputerAudio\Music\ChillingMusic.wav",
            AudioPlayMode.WaitToComplete)

    "My" is showing red squeegly line am i missing a Imports statement and references 

    regards

    Manoj gokhale

    Wednesday, August 14, 2019 1:35 PM

All replies

  • Hi

    You need to show context - ie WHERE is that line of code with respect to all the other code (I am wondering if you did not put it inside a Sub)


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, August 14, 2019 2:10 PM
    Wednesday, August 14, 2019 2:10 PM
  • Hello,

    That code is valid in a sub procedure or function. So if you are attempting to use this code outside of a sub or function in a Windows Form project it will not work. Otherwise My namespace is available.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, August 14, 2019 2:16 PM
    Moderator
  • Imports Microsoft
    Imports MyComp
    Imports System
    
    
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Dim musicPath As String = "F:\00001\00001 VB\MyComputerAudio\Music\ChillingMusic.wav"
    
            My.Computer.Audio.Play(musicPath, AudioPlayMode.Background)
    
            My.Computer.Audio.Play(musicPath, AudioPlayMode.BackgroundLoop)
    
            My.Computer.Audio.Play(musicPath, AudioPlayMode.WaitToComplete)
        End Sub
    End Class
    I have attached the code
    Wednesday, August 14, 2019 2:32 PM
  • Imports Microsoft
    Imports MyComp
    Imports System
    
    
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Dim musicPath As String = "F:\00001\00001 VB\MyComputerAudio\Music\ChillingMusic.wav"
    
            My.Computer.Audio.Play(musicPath, AudioPlayMode.Background)
    
            My.Computer.Audio.Play(musicPath, AudioPlayMode.BackgroundLoop)
    
            My.Computer.Audio.Play(musicPath, AudioPlayMode.WaitToComplete)
        End Sub
    End Class
    I have attached the code

    I see no issues but must ask, what is MyComp import for? And note that zero import statements are required. As per

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) _
            Handles Button1.Click
    
            Dim musicPath As String =
                    "F:\00001\00001 VB\MyComputerAudio\Music\ChillingMusic.wav"
    
            My.Computer.Audio.
                Play(musicPath, AudioPlayMode.Background)
    
            My.Computer.Audio.
                Play(musicPath, AudioPlayMode.BackgroundLoop)
    
            My.Computer.Audio.
                Play(musicPath, AudioPlayMode.WaitToComplete)
        End Sub
    End Class
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, August 14, 2019 2:40 PM
    Moderator
  • Hello

    The error mesage is

    ==> (BC30451)

    My is not declared It may be inaccessible due to its protection level

    regards

    Manoj Gokhale

    Thursday, August 15, 2019 5:53 AM
  • Hello

    I am waiting please reply asap

    regds

    Manoj Gokhale

    Thursday, August 15, 2019 6:19 AM
  • Hello

    I am waiting please reply asap

    regds

    Manoj Gokhale

    Hello,

    I would ask you to do the following and do nothing else.

    • Create a new Windows Forms project for VB.NET.
    • In Form1, add a button and double click the button.
    • Add the code below.
    • Build the project.
    • What happened?
    Dim musicPath As String =
    		"F:\00001\00001 VB\MyComputerAudio\Music\ChillingMusic.wav"
    
    My.Computer.Audio.
    	Play(musicPath, AudioPlayMode.Background)
    
    My.Computer.Audio.
    	Play(musicPath, AudioPlayMode.BackgroundLoop)
    
    My.Computer.Audio.
    	Play(musicPath, AudioPlayMode.WaitToComplete)

    In closing, the only way I see your original code not working is that you may have worked on code that was not something that should be edited, you are running a .NET Core project or removed references that caused the current issue.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, August 15, 2019 10:33 AM
    Moderator