vb.net Ignore stepping through certain functions when using F5 - vb.net

When I use the debugger and F5 to follow along what is currently being called in my app, I have some functions which I don't want the debugger to go through.
These functions are not important to me, and I know what they are doing. Having the debugger step through each line of this function is just taking my time.
How could I make it so that the debugger ignores the function?
Thank you!

With the help of #Jimi, I found a VB.net solution.
One has to add
<DebuggerStepThrough()>
over the first line of the function.
For example:
<DebuggerStepThrough()>
Public Function StrLen(ByVal uString As String) As Integer
If (Not uString Is Nothing) AndAlso (Not uString = String.Empty) Then
Return uString.Length
Else
Return 0
End If
End Function

Related

VB.NET GetProcessesByName method is missing

I'm building a program in VB whose purpose is to run in the background and automatically update other programs I've created. To do this, it has to check if those programs are still running and, if they are, wait for them to close.
Unfortunately, the program won't compile. The exception states: GetProcessesByName is not a member of String. (The string it refers to is the Process parameter shown in the code below.)
I can't understand why this is happening, because this method has always worked without problems. I'm using Visual Studio 2015. For your reference, here's the code block:
Private Function CheckIfRunning(Process As String) As Boolean
Dim MyProcess() As Process
MyProcess = Process.GetProcessesByName("ProcessName")
If MyProcess.Count > 0 Then
Return True
Else
Return False
End If
End Function
Try using System.Diagnostics.Process.GetProcessesByName("ProcessName")
Since you've declared Process as a string parameter, Process.GetProcessesByName refers to the string instead of the System.Diagnostics method. Alternatively, you can use a different name for the string parameter.

SignalR Siverlight Cliet side code

I am trying to write a simplest silverlight client code for method which can be called from server without parameters. Bellow is my code in VB:
hubProxy.On(Of String)("received", Function() Context.Post(Sub() textBox.Text += "Notified!", Nothing))
But I am getting error “Expression does not produce a value”.
Any help please.
In VB.NET Functions must return a value. Since your anonymous function only has one expression, Context.Post(Sub() textBox.Text += "Notified!", Nothing), the value produced by that expression is returned by the Function. The problem is that your one expression doesn't produce a value at all.
Since Context.Post is itself a Sub (or void-returning in C/C# parlance) instead of a Function, there is no value to return from the Function you pass to hubProxy.On.
Long story short: the Function you are passing into hubProxy.On should really be a Sub since it doesn't return a value. You are already using an anonymous Sub in your call to Context.Post:
hubProxy.On(Of String)("received",
Sub() Context.Post(Sub() textBox.Text += "Notified!", Nothing)

Delegate function to return value

I am trying to get value from the delegate function. Basically I am trying to get the richboxtext line length from delegate function.
Here is my function
Private Delegate Function getrichlengthmain(ByVal TB As RichTextBox) As String
Private Function getrichlenghtdele(ByVal TB As RichTextBox) As string
Return TB.Lines.Length
End Function
And I am calling it by
Dim d As getrichlengthmain
d = AddressOf getrichlenghtdele
dim returnvalue as string
returnvalue = d.BeginInvoke(FstList,nothing,nothing)
2 problems in this code
1st problem
when I change the code from "returnvalue = d.BeginInvoke(FstList,nothing,nothing)" to "d.BeginInvoke(FstList,nothing,nothing)"
The cross-thread error popout while debuiging
2nd problem
How do I get the value from the function without getting any cross thread error.
Very thanks for your time and thanks in advance for solving it.
You are experiencing an error because the control you are trying to access was created on a different thread from the one you are accessing it on. This is a common mistake when developing threaded UI applications in .Net.
There are (at least) two ways to tackle the problem you have, the lazy way and the correct way. To solve this the lazy way, you simply stop the check for illegal cross-threading calls to controls from taking place by including this line of code somewhere in your UI component:
Control.CheckForIllegalCrossThreadCalls = False
A better way to deal with the problem is to ensure you code executes on the correct thread (therefore maintaining thread safety). One method of accomplishing this is described here.

VB.net check if program is in startup?

so i have this code
My.Computer.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue("WooW")
But before i perform that code i wanna see if that program / key is in startup
can any one help me with that? please
Using subKey As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
If subKey.GetValue("WooW") <> Nothing Then
subKey.DeleteValue("Woow")
End If
End Using
If a value does not exist the GetValue() function will yield Null signified using Nothing in Visual Basic. If you want, you could pass a second argument to DeleteValue() that will cause the function to throw should the value not exist subKey.DeleteValue("Woow", True)

Object reference not set to an instance of an object (Completely broken?) in vb.net

I know, I know, I could have used a for loop, dont tell me anything about that. Please, help!
Private Function LoadSaved() ''//Loads saved clippings if the user wants us to
Dim ZomgSavedClips As StringCollection
If IsDBNull(My.Settings.SavedClips) = False Then ''//If it is null this would return a rather ugly error. Dont want that do we?
ZomgSavedClips = My.Settings.SavedClips ''//ZomgSavedClips name was a joke, I just felt like it.
ZomgSavedClips.Add(" ") ''//This line ought to fix the error, but doesnt
i = 0
While i < ZomgSavedClips.Count ''//This is where the error occurs
ClipListings.Rows.Add(ZomgSavedClips(i))
i = i + 1 ''//First time I wrote this function I forgot this line. Crashed mah comp. Fail.
End While
End If
End Function
The line While i < ZomgSavedClips.Count is bugging, I know that the .count should return null but I even added a blank piece of text just to stop that. Whats up with this? Should I add actual text?
SavedClips is null no? If it is null it could pass the test IsDBNull beacuse the both are not the same
Obviously, My.Settings.SavedClips is still set to Nothing.
SavedClips is regular 'ole null (nothing in VB). Include a check for "My.Settings.SavedClips is nothing". If that evaluates to true then just leave the function.
I even added a blank piece of text just to stop that.
All you did was move where the error happens. You can't call .Add() on a null/Nothing object.
'''<summary>Loads saved clippings if the user wants us to</summary>'
Private Sub LoadSaved() ''//Loads saved clippings if the user wants us to
''//Load saved clips into memory
Dim ZomgSavedClips As StringCollection = My.Settings.SavedClips
If ZomgSavedClips Is Nothing Then ZomgSavedClips = New StringCollection()
''//Apply loaded clips to visible listings
Dim i As Integer
While i < ZomgSavedClips.Count ''
ClipListings.Rows.Add(ZomgSavedClips(i))
i += 1
End While
End Sub
Some notes on this code:
Don't use Function when you mean Sub
Since you'll be selling this code to others, you want to use xml comments at the top so that Visual Studio can give better intellisense helps.
IsDBNull() doesn't do what you think it does.
Yes, you should use a for loop, but since you already commented on that I left the while loop alone with the assumption that there's more code you didn't show us.