I am in the process of building a website in Visual Studio 2010 using Visual Basic and I am trying to have an item in a Drop Down List when clicked, it will open a dialog box that will prompt the user to enter in some information. I have tried searching i haven't found any code that works. Here is the code I have so far;
Protected Sub MonthDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MonthDropDownList.SelectedIndexChanged
If MonthDropDownList.SelectedValue = "Add Month" Then
End If
End Sub
Related
When debugging in a Visual Basic Project in Visual Studio 2019, I can't see the values of parameters inside a With-Block when I'm hovering over it with the mouse.
I have Resharper Ultimate installed, but it seems like it doesn't provide a function to show it either.
When using a With-Block the values of ".Name", ".URL", etc.
aren't shown when hovering over them in debug mode:
Private Sub AddCustomer()
Dim theCustomer As New Customer
With theCustomer
.Name = "Coho Vineyard"
.URL = "http://www.cohovineyard.com/"
.City = "Redmond"
End With
With theCustomer.Comments
.Add("First comment.")
.Add("Second comment.")
End With
End Sub
When it is this way, the debugger shows the values just as usual:
Private Sub AddCustomer()
Dim theCustomer As New Customer
theCustomer.Name = "Coho Vineyard"
theCustomer.URL = "http://www.cohovineyard.com/"
theCustomer.City = "Redmond"
theCustomer.Comments.Add("First comment.")
theCustomer.Comments.Add("Second comment.")
End Sub
How can I see the values? Or is there a way to convert the With-Blocks automatically to regular expressions?
Works for me:
Are you sure that you are talking about VB6? Resharper Ultimate sounds more like an extension for Visual Studio.
I can't see the values of parameters inside a With-Block when I'm
hovering over it with the mouse.
Do you use DataTips?
I test it in VS2019 16.1(Community and Professional Edition). In a VB.net console app using your example code, we can use DataTips to monitor variable value in debug mode.
Hover over the thecustomer variable and we can get its details during debugging.If this option not work in your side, try repairing VS or update it to latest VS version.
Hope it helps:)
I have this simple vbscript, but windows gives me an error when I'm trying to run it. I've never worked with vbscript before and i tried to google, but could figure out why. I'm getting expected end of line error at line 1, character 16. Does anyone see anything?
Also, I'm coding this in notepad and running it by double clicking the file. Is there any other way i should do it?
Dim WithEvents Button As CommandButton
Private Sub Application_StartUp(Cancel As Boolean)
Set Button = CommandButtons.Add("Click me")
End SubPrivate Sub Button_Click()
Msgbox "Clicked", vbInformation
End Sub
Since it was mentioned that notepad is being used for this and looking at the code this certainly appears to be code to add a button to a Form Based application using VBScript in Visual Studio.
VBScript via notepad is not really good at being used for creating GUI dialog boxes and such. A sample code of what would work using Notepad is as such:
toRepeat = InputBox("What should I repeat?", "Echo", "Hello World")
MsgBox toRepeat
Whatever is typed in to the input box will be repeated in this example.
If Visual Studio is not available and there is an interest in building a form based application then it may be possible to create User Forms in VBA via Word or Excel. The following site gives a good tutorial for creating a User Form application in Excel: Excel VBA Userform - Easy Excel Macros
In case there is interest, I recently wrote in to my blog an explanation of the different flavors of VB that are available: VBA vs VBSCRIPT vs Visual Basic
Thanks,
Sean W.
I am looking to create a Visual Studio AddIn which can help me launch my own debugging process. I want to keep the original F5 based debugging intact and hence i do not want to intercept that call and need a separate AddIn.
Any suggestions
The easiest way is to capture the system events/macros using an addin. It is really easy to override what vs does in these events. All the events are automatically fired when using the standard visual studio commands such as F5. This includes all of the standard visual studio shortcut keys, menus and tool bar buttons.
Create a new vs addin project and it will automatically add the code to attach the OnBeforeCommandEvent. In vb the event handler will look like the code below.
Friend Sub OnBeforeCommandEvent(sGuid As String, ID As Integer, CustomIn As Object, CustomOut As Object, ByRef CancelDefault As Boolean)
The event passes you sGuid and ID. You can resolve these two items to a macro string name (sCommandName) as follows:-
Dim objCommand As EnvDTE.Command
Try
objCommand = _applicationObject.Commands.Item(sGuid, ID)
Catch ex As Exception
'unknown guids can be ignored
Exit Sub
End Try
If objCommand Is Nothing Then Exit Sub
Dim sCommandName As String
sCommandName = objCommand.Name
nb: The _applicationObject is passed to your code when the addin starts. A new addin project will automatically inlude the following code for the OnConnection event, the first argument is the _applicationObject shown above.
OnConnection(ByVal application As Object
Once you have the sCommandName variable it will contain the name of a Visual Studio macro such as Debug.Start.
To override the Debug.Start functions then you would add some of your own code and remember to set CancelDefault to True before you exit the handler.
When you set CancelDefault to true Visual Studio will not run the standard macro which means you can run your own debugger when F5 is pressed.
These are Visual Studio macro names that are used during the build process. You can override as many or as few as you like. I have grouped them into their related functionality but you can handle them in any combination.
Select Case sCommandName
Case "Debug.Start", _
"Debug.StartWithoutDebugging"
System.Windows.Forms.MessageBox.Show("You clicked F5, we are overriding the debug process")
CancelDefault=true
Exit Sub
Case "ClassViewContextMenus.ClassViewProject.Rebuild", _
"ClassViewContextMenus.ClassViewProject.Build", _
"Build.RebuildOnlyProject", _
"Build.RebuildSelection", _
"Build.BuildOnlyProject", _
"Build.BuildSelection"
Case "Build.RebuildSolution", _
"Build.BuildSolution"
Case "ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance", _
"ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance"
Case "Build.CleanSelection", _
"Build.CleanSolution", _
"ClassViewContextMenus.ClassViewProject.Clean"
Case "Build.SolutionConfigurations"
Is there way to automatically maximize the output window on hitting build and then to automatically restore to previous state when the build completes?
You could create a macro that builds the solution then activates the output window. For example:
DTE.ExecuteCommand("Build.BuildSolution")
DTE.Windows.Item(Constants.vsWindowKindOutput).Activate()
You could then replace the Build button or the build keyboard shortcut to execute that macro.
I could implement a solution using a combination of macros.
Part of the solution is in this SO question:
OnBuildBegin does not fire in Visual Studio Macro until I run it from Macro Explorer
And the other part is to use 2 exported window settings and to toggle them on build events.
Something like:
Public Sub BuildEvents_OnBuildBegin() Handles BuildEvents.OnBuildBegin
DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:C:\Development\VsSettings\build_inprocess.vssettings")
End Sub
Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) _
Handles BuildEvents.OnBuildDone
DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:C:\Development\VsSettings\Two_Screen.vssettings")
End Sub
I have an add-in that contains a DLL and an OCX control, built in VB6. Each is separate, meaning that the add-in consists of Addin.DLL and Addin.OCX. The add-in uses a custom form, which is built off of the IPM.Appointment form in Outlook. It is deployed to the user's machine as an OFT file and is published to their Presonal Forms Library in the initial OnConnection of the add-in.
I was having issues with the form being stuck in a one off state, which required me to add code similar the following to my AppointmentItem Write and PropertyChange class:
Private Sub AppointmentItem_PropertyChange(ByVal name As String)
On Error GoTo ErrorHandler
Select Case name
Case "MessageClass"
Dim strGuid As String
' Check to see if this is one of our appointmentitems.
If IsItemUserItem(AppointmentItem_PropertyChange, strGuid) Then
' Change to our add-in message class. IPM.Appointment.XXX
AppointmentItem.MessageClass = gFormMsgClass
End If
End Select
done:
Exit Sub
ErrorHandler:
Trace "Error writing appointment item."
Resume done
End Sub
This works for most cases. However, I'm still running into instances where when I check the item during the NewInspector event if it is an Exception I cannot access UserProperties, which are used to facilitate data sharing between the DLL and OCX.
Additionally when trying to edit the form in the form designer, I cannot save the form as an OFT from Outlook 2007. I'm kind of at a loss as to what is going on with this...Any help is appreciated.
Actually it appears I have my own answer. There were some user-defined properties added to the folder that were not added to the item and they were causing the one off issues.