Click here to Skip to main content
15,884,537 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Accessing a known Outlook subfolder Pin
Member 1205805425-Sep-20 4:25
Member 1205805425-Sep-20 4:25 
GeneralRe: Accessing a known Outlook subfolder Pin
Member 1205805425-Sep-20 8:30
Member 1205805425-Sep-20 8:30 
QuestionVISUAL STUDIO 2010 , REQUIRED CODING FOR MANAGE STOCK BALANCE ITEM WISE Pin
Raza Askari19-Sep-20 0:22
Raza Askari19-Sep-20 0:22 
AnswerRe: VISUAL STUDIO 2010 , REQUIRED CODING FOR MANAGE STOCK BALANCE ITEM WISE Pin
Richard MacCutchan19-Sep-20 2:26
mveRichard MacCutchan19-Sep-20 2:26 
GeneralRe: VISUAL STUDIO 2010 , REQUIRED CODING FOR MANAGE STOCK BALANCE ITEM WISE Pin
Raza Askari20-Sep-20 20:47
Raza Askari20-Sep-20 20:47 
AnswerRe: VISUAL STUDIO 2010 , REQUIRED CODING FOR MANAGE STOCK BALANCE ITEM WISE Pin
Dave Kreskowiak19-Sep-20 5:05
mveDave Kreskowiak19-Sep-20 5:05 
AnswerRe: VISUAL STUDIO 2010 , REQUIRED CODING FOR MANAGE STOCK BALANCE ITEM WISE Pin
Richard Andrew x6421-Sep-20 11:38
professionalRichard Andrew x6421-Sep-20 11:38 
QuestionVB.NET: Failes to assign an Action to a method Pin
Mc_Topaz16-Sep-20 23:24
Mc_Topaz16-Sep-20 23:24 
I require to assign an Action to a method.
I can do this in C# without problem.
But when I port the C# code to VB.NET I fail at one line.
My company has a VB.NET application where we require this solution.

I have created a small and reproducible solution regarding this in both a C# and VB.
Of course this is not the real solution I have, but the problem is same.

C# code
C#
namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            var foo = new Foo();
            foo.Bar = Qux;    // This line fails in VB.NET.
            foo.Baz();
        }

        static void Qux()
        {
            Console.WriteLine(nameof(Qux));
        }
    }

    class Foo
    {
        public Action Bar { get; set; }
        public void Baz()
        {
            Bar();
        }
    }
}
VB.NET code
VB
Module Module1
    Sub Main()
        Dim foo As Foo = New Foo()
        foo.Bar = Qux()    ' This line failes.
        foo.Baz()
    End Sub

    Sub Qux()
        Console.WriteLine(NameOf(Qux))
    End Sub

    Class Foo
        Private b As Action
        Public Property Bar() As Action
            Get
                Return b
            End Get
            Set(ByVal value As Action)
                b = value
            End Set
        End Property

        Public Sub Baz()
            b()
        End Sub
    End Class

End Module
The compile error message: Expression does not produce a value

VB.NET is not my primary language and I'm sure I have made some very basic mistake.
I don't like to ask for a solution, but I cannot find the correct way to do this.
Please provide me with the correct solution to fix this.
AnswerRe: VB.NET: Failes to assign an Action to a method Pin
Richard Deeming16-Sep-20 23:46
mveRichard Deeming16-Sep-20 23:46 
GeneralRe: VB.NET: Failes to assign an Action to a method Pin
Mc_Topaz17-Sep-20 0:46
Mc_Topaz17-Sep-20 0:46 
QuestionDataView Sort Pin
jkirkerx16-Sep-20 14:11
professionaljkirkerx16-Sep-20 14:11 
AnswerRe: DataView Sort Pin
Richard Deeming16-Sep-20 23:43
mveRichard Deeming16-Sep-20 23:43 
GeneralRe: DataView Sort Pin
jkirkerx17-Sep-20 4:42
professionaljkirkerx17-Sep-20 4:42 
GeneralRe: DataView Sort Pin
Richard Deeming17-Sep-20 9:07
mveRichard Deeming17-Sep-20 9:07 
GeneralRe: DataView Sort Pin
jkirkerx17-Sep-20 11:28
professionaljkirkerx17-Sep-20 11:28 
SuggestionRe: DataView Sort Pin
Richard Deeming17-Sep-20 21:36
mveRichard Deeming17-Sep-20 21:36 
GeneralRe: DataView Sort Pin
jkirkerx18-Sep-20 7:56
professionaljkirkerx18-Sep-20 7:56 
GeneralRe: DataView Sort Pin
jkirkerx18-Sep-20 8:00
professionaljkirkerx18-Sep-20 8:00 
GeneralRe: DataView Sort Pin
Gerry Schmitz18-Sep-20 8:10
mveGerry Schmitz18-Sep-20 8:10 
GeneralRe: DataView Sort Pin
Richard Deeming20-Sep-20 23:38
mveRichard Deeming20-Sep-20 23:38 
GeneralRe: DataView Sort Pin
jkirkerx21-Sep-20 6:07
professionaljkirkerx21-Sep-20 6:07 
QuestionRun multiple SSH commands without disconnecting Pin
droidman16-Sep-20 1:56
droidman16-Sep-20 1:56 
Questioni have tried the code above . it works fine. but it only shows the breakdown of the costs. i want the label to show the total cost as well. what more should i add to the code?? please help</pre> Pin
Rikansha kumar10-Sep-20 22:10
Rikansha kumar10-Sep-20 22:10 
Rant[REPOST]: i have tried the code above . it works fine. but it only shows the breakdown of the costs. i want the label to show the total cost as well. what more should i add to the code?? please help</pre> Pin
Richard Deeming10-Sep-20 22:22
mveRichard Deeming10-Sep-20 22:22 
QuestionVB6 Pin
Devam Dani28-Aug-20 16:26
Devam Dani28-Aug-20 16:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.