Click here to Skip to main content
15,905,508 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Create Guitar Tunner using Vb.net Pin
Mangore759-Jan-12 22:52
Mangore759-Jan-12 22:52 
GeneralRe: Create Guitar Tunner using Vb.net Pin
Dave Kreskowiak10-Jan-12 2:07
mveDave Kreskowiak10-Jan-12 2:07 
QuestionLogin Form Pin
Taherhamdy7-Jan-12 19:39
Taherhamdy7-Jan-12 19:39 
AnswerRe: Login Form Pin
Simon_Whale8-Jan-12 4:18
Simon_Whale8-Jan-12 4:18 
QuestionMulti Player Sample Help Pin
mholmes30386-Jan-12 10:10
mholmes30386-Jan-12 10:10 
AnswerRe: Multi Player Sample Help Pin
Kevin Schaefer10-Jan-12 16:33
Kevin Schaefer10-Jan-12 16:33 
GeneralRe: Multi Player Sample Help Pin
mholmes303812-Jan-12 8:30
mholmes303812-Jan-12 8:30 
Questionneed help pls Pin
zakari mohammed6-Jan-12 5:37
zakari mohammed6-Jan-12 5:37 
AnswerRe: need help pls Pin
Simon_Whale6-Jan-12 6:05
Simon_Whale6-Jan-12 6:05 
AnswerRe: need help pls Pin
David Mujica6-Jan-12 6:06
David Mujica6-Jan-12 6:06 
GeneralRe: need help pls Pin
zakari mohammed6-Jan-12 6:16
zakari mohammed6-Jan-12 6:16 
AnswerRe: need help pls Pin
Luc Pattyn6-Jan-12 7:08
sitebuilderLuc Pattyn6-Jan-12 7:08 
GeneralRe: need help pls Pin
zakari mohammed10-Jan-12 23:26
zakari mohammed10-Jan-12 23:26 
AnswerRe: need help pls Pin
RobCroll8-Jan-12 18:44
RobCroll8-Jan-12 18:44 
GeneralRe: need help pls Pin
zakari mohammed10-Jan-12 23:14
zakari mohammed10-Jan-12 23:14 
AnswerRe: need help pls Pin
Abhinav S8-Jan-12 19:42
Abhinav S8-Jan-12 19:42 
QuestionAdding text to the beginning of a file rather than the end Pin
Marcus J. Smith4-Jan-12 5:55
professionalMarcus J. Smith4-Jan-12 5:55 
AnswerRe: Adding text to the beginning of a file rather than the end Pin
Dave Kreskowiak4-Jan-12 7:10
mveDave Kreskowiak4-Jan-12 7:10 
GeneralRe: Adding text to the beginning of a file rather than the end Pin
Marcus J. Smith4-Jan-12 7:38
professionalMarcus J. Smith4-Jan-12 7:38 
AnswerRe: Adding text to the beginning of a file rather than the end Pin
Luc Pattyn4-Jan-12 7:38
sitebuilderLuc Pattyn4-Jan-12 7:38 
AnswerRe: Adding text to the beginning of a file rather than the end Pin
Eddy Vluggen4-Jan-12 11:53
professionalEddy Vluggen4-Jan-12 11:53 
QuestionOpen word doc inside WebBrowser control on Win7 machine Pin
Nitin Varshneya3-Jan-12 5:54
Nitin Varshneya3-Jan-12 5:54 
AnswerBumping repost alert Pin
Luc Pattyn3-Jan-12 6:48
sitebuilderLuc Pattyn3-Jan-12 6:48 
AnswerRe: Open word doc inside WebBrowser control on Win7 machine Pin
Dave Kreskowiak3-Jan-12 9:37
mveDave Kreskowiak3-Jan-12 9:37 
Question[Resolved] C# to VB Adaption Problem with Lambda Expressions Pin
Sonhospa1-Jan-12 3:27
Sonhospa1-Jan-12 3:27 
Hi guys,

I hope you had a nice start into 2012!

I've been trying to convert this^ piece of code into VB, using VS Express 2010 and #Develop. In order to avoid problems with conversion of c# 'yield' operator, I put the extensions into a DLL and set a reference to that.

The translated code of the test implementation reads like:
Shared Sub Main(ByVal args() As String)
    Dim worker As New BackgroundWorker()
    worker.WorkerReportsProgress = True
    AddHandler worker.DoWork, Function(sender, e)
    ' pretend we have a collection of items to process
    Dim items(999) As Integer
    items.WithProgressReporting(Function(progress) worker.ReportProgress(progress)).ForEach(Function(item) Thread.Sleep(10)) ' simulate some real work
    End Function

    AddHandler worker.ProgressChanged, Function(sender, e)
    ' make sure the figure is written to the
    ' same point on screen each time
    Console.SetCursorPosition(1, 0)
    Console.Write(e.ProgressPercentage)
    End Function

    worker.RunWorkerAsync()
    Console.Read()
End Sub

Unfortunately in VB the line
items.WithProgressReporting(Function(progress) worker.ReportProgress(progress).ForEach(Function(item) Thread.Sleep(10)))
throws an exception "Expression does not produce a value" at the underlined place. There's no such exception in C# where the test code compiles and executes fine.

Having to implement the technique into my VB application, I'd like to understand where the problem arises. Could anyone of you tell me what's wrong in the (automatic) translation of the Lambda expression?

Thank you
Mick

modified 10-Jan-12 5:23am.

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.