Click here to Skip to main content
15,890,438 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionIs there Access VBA method of translating text in a textbox? Pin
Member 1181158314-Dec-20 3:18
Member 1181158314-Dec-20 3:18 
AnswerRe: Is there Access VBA method of translating text in a textbox? Pin
Richard Deeming14-Dec-20 4:02
mveRichard Deeming14-Dec-20 4:02 
GeneralRe: Is there Access VBA method of translating text in a textbox? Pin
Member 1181158314-Dec-20 4:56
Member 1181158314-Dec-20 4:56 
GeneralRe: Is there Access VBA method of translating text in a textbox? Pin
Member 1181158314-Dec-20 11:41
Member 1181158314-Dec-20 11:41 
QuestionVisual Studio RDLC expression editor in the report designer and help with expressions Pin
jkirkerx5-Dec-20 10:26
professionaljkirkerx5-Dec-20 10:26 
AnswerRe: Visual Studio RDLC expression editor in the report designer and help with expressions Pin
jkirkerx5-Dec-20 13:10
professionaljkirkerx5-Dec-20 13:10 
AnswerRe: Visual Studio RDLC expression editor in the report designer and help with expressions [solved] Pin
jkirkerx6-Dec-20 9:35
professionaljkirkerx6-Dec-20 9:35 
QuestionCall a method inside a Task.Run and return the value Pin
Mc_Topaz2-Dec-20 3:03
Mc_Topaz2-Dec-20 3:03 
I have a method Bar.
Bar take some arbitrary amount of time to complete.
I want to call Bar from a method Foo.
Foo run some code sync and last run Bar async.
Bar returns a value and I want Foo to return the same value.

Here is the code to reproduce the behavior:
VB
Module Module1

    Sub Main()
        Dim i As Integer = Foo()
        Console.Write("Enter anything: ")
        Console.ReadLine()
        Console.WriteLine(i)
    End Sub

    Async Function Foo() As Task(Of Integer)
        Console.WriteLine("Do something sync")
        Console.WriteLine("Do something sync")
        Return Await Task.Run(Function() Bar())
    End Function

    Function Bar() As Integer
        Console.WriteLine("Bar Start")
        Threading.Thread.Sleep(2000)
        Console.WriteLine("Bar Stop")
        Return 5
    End Function

End Module
But I get a compile error in the Main method:
VB
Dim i As Integer = Foo()
Value of type Task(Of Integer) cannot be converted to Integer.
I understand the error, but I don't understand how I should solve it.

I tried this line:
VB
Dim i As Integer = Foo().Result
Which compiles and runs. But the call to the Bar method ran sync, not async.

How should I alter the code to run Bar async and from Foo only return the value from Bar?
AnswerRe: Call a method inside a Task.Run and return the value Pin
Richard MacCutchan2-Dec-20 3:23
mveRichard MacCutchan2-Dec-20 3:23 
AnswerRe: Call a method inside a Task.Run and return the value Pin
Gerry Schmitz2-Dec-20 5:23
mveGerry Schmitz2-Dec-20 5:23 
Questionvb.net addin won't run in release mode Pin
JR21230-Nov-20 23:53
JR21230-Nov-20 23:53 
AnswerRe: vb.net addin won't run in release mode Pin
BabyYoda1-Dec-20 5:53
BabyYoda1-Dec-20 5:53 
GeneralRe: vb.net addin won't run in release mode Pin
JR2121-Dec-20 6:22
JR2121-Dec-20 6:22 
QuestionRe: vb.net addin won't run in release mode Pin
Richard MacCutchan1-Dec-20 6:36
mveRichard MacCutchan1-Dec-20 6:36 
QuestionCreate Multi Series Chart in VB.net Pin
Member 1500024122-Nov-20 21:46
Member 1500024122-Nov-20 21:46 
AnswerRe: Create Multi Series Chart in VB.net Pin
Richard Deeming22-Nov-20 22:22
mveRichard Deeming22-Nov-20 22:22 
Questionneed some guidance and advice to build a questionnaire system similar to Google forms in vb.net or c# and sql server Pin
albasheer210019-Nov-20 18:05
albasheer210019-Nov-20 18:05 
AnswerRe: need some guidance and advice to build a questionnaire system similar to Google forms in vb.net or c# and sql server Pin
Richard MacCutchan19-Nov-20 22:14
mveRichard MacCutchan19-Nov-20 22:14 
AnswerRe: need some guidance and advice to build a questionnaire system similar to Google forms in vb.net or c# and sql server Pin
CHill6020-Nov-20 1:59
mveCHill6020-Nov-20 1:59 
QuestionSend a file via a bot telegram vb.net Pin
Member 1496222414-Nov-20 11:33
Member 1496222414-Nov-20 11:33 
AnswerRe: Send a file via a bot telegram vb.net Pin
Dave Kreskowiak14-Nov-20 12:14
mveDave Kreskowiak14-Nov-20 12:14 
QuestionChanging the color of specific text and selecting visual basics word Pin
DaniOM9-Nov-20 1:25
DaniOM9-Nov-20 1:25 
AnswerRe: Changing the color of specific text and selecting visual basics word Pin
CHill6017-Nov-20 23:59
mveCHill6017-Nov-20 23:59 
QuestionProblem in sending sms Pin
Member 137109127-Nov-20 4:44
Member 137109127-Nov-20 4:44 
AnswerRe: Problem in sending sms Pin
Richard Andrew x647-Nov-20 8:46
professionalRichard Andrew x647-Nov-20 8:46 

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.