Skip to content

Commit

Permalink
Remove ByVal, add ReadOnly where appropiate and add missing As Clause… (
Browse files Browse the repository at this point in the history
#1201)

* Remove ByVal, add ReadOnly where appropiate and add missing As Clause to remove messages from VS 2019.

* Remove ByRef

* Respond to feedback, restore autogenerated file and don't upload sln file

* Remove ByVal, Add ReadOnly when required

* Remove ByRef and upgrade project files to VS2019, simplify object initialization, simpiliy some types.

* Delete .GitIgnore, add WinFormGraphics_VB to solution and port matchinggame to Visual Basic.

* Restore .Gitignore
  • Loading branch information
paul1956 authored and Ron Petrusha committed Aug 29, 2019
1 parent 7cd1fc1 commit a84ae9a
Show file tree
Hide file tree
Showing 54 changed files with 3,272 additions and 2,543 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ samples/framework/docker/MVCRandomAnswerGenerator/containerImage
_dependentPackages/

# Visual Studio Code
.vscode/
.vscode/
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

Partial Friend Class MyApplication
'<snippet51>
Protected Overrides Function OnInitialize(
ByVal commandLineArgs As System.Collections.
ObjectModel.ReadOnlyCollection(Of String)
Protected Overrides Function OnInitialize(
commandLineArgs As System.Collections.
ObjectModel.ReadOnlyCollection(Of String)
) As Boolean
' Set the display time to 5000 milliseconds (5 seconds).
Me.MinimumSplashScreenDisplayTime = 5000
Expand All @@ -20,27 +20,27 @@
'</snippet51>

'<snippet9>
Private Sub MyApplication_NetworkAvailabilityChanged(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs
Private Sub MyApplication_NetworkAvailabilityChanged(
sender As Object,
e As Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs
) Handles Me.NetworkAvailabilityChanged
My.Forms.Form1.SetConnectionStatus(e.IsNetworkAvailable)
End Sub
'</snippet9>

'<snippet13>
Private Sub MyApplication_Shutdown(
ByVal sender As Object,
ByVal e As System.EventArgs
Private Sub MyApplication_Shutdown(
sender As Object,
e As System.EventArgs
) Handles Me.Shutdown
My.Application.Log.WriteEntry("Application Shut Down.")
End Sub
'</snippet13>

'<snippet14>
Private Sub MyApplication_Startup(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs
Private Sub MyApplication_Startup(
sender As Object,
e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs
) Handles Me.Startup
' Get the splash screen.
Dim splash As SplashScreen1 = CType(My.Application.SplashScreen, SplashScreen1)
Expand All @@ -55,9 +55,9 @@
' End While

'<snippet15>
Private Sub MyApplication_StartupNextInstance(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs
Private Sub MyApplication_StartupNextInstance(
sender As Object,
e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs
) Handles Me.StartupNextInstance
Dim inputArgument As String = "/input="
Dim inputName As String = ""
Expand All @@ -77,13 +77,13 @@
'</snippet15>

'<snippet17>
Private Sub MyApplication_UnhandledException(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs
Private Sub MyApplication_UnhandledException(
sender As Object,
e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs
) Handles Me.UnhandledException

My.Application.Log.WriteException(e.Exception,
TraceEventType.Critical,
My.Application.Log.WriteException(e.Exception,
TraceEventType.Critical,
"Unhandled Exception.")
End Sub
'</snippet17>
Expand All @@ -94,9 +94,9 @@ End Namespace
Class FakeMyApp : Inherits Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
'<snippet40>
'<snippet41>
Private Sub MyApplication_Startup(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs
Private Sub MyApplication_Startup(
sender As Object,
e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs
) Handles Me.Startup
'</snippet41>
'<snippet43>
Expand Down Expand Up @@ -124,4 +124,4 @@ Class FakeMyApp : Inherits Microsoft.VisualBasic.ApplicationServices.WindowsForm
End Class
'</snippet40>

End Class
End Class

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ Option Strict On

Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim start As New Threading.ThreadStart(AddressOf launch)
Dim t As System.Threading.Thread
t = New System.Threading.Thread(start)
t.Start()

End Sub

Public Shared Sub MsgBox(ByVal s As String)
Public Shared Sub MsgBox(s As String)
Form1.TextBox1.Text &= s & vbCrLf
Microsoft.VisualBasic.MsgBox(s)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
testAppInfo()
End Sub

Expand Down Expand Up @@ -64,14 +64,14 @@ Public Class Form1

'<snippet12>
Private Sub InitializeSaveMySettingsOnExit()
SaveMySettingsOnExit.Checked =
SaveMySettingsOnExit.Checked =
My.Application.SaveMySettingsOnExit
End Sub
Private Sub SaveMySettingsOnExit_CheckedChanged(
ByVal sender As System.Object,
ByVal e As System.EventArgs
Private Sub SaveMySettingsOnExit_CheckedChanged(
sender As System.Object,
e As System.EventArgs
) Handles SaveMySettingsOnExit.CheckedChanged
My.Application.SaveMySettingsOnExit =
My.Application.SaveMySettingsOnExit =
SaveMySettingsOnExit.Checked
End Sub
'</snippet12>
Expand Down Expand Up @@ -112,8 +112,8 @@ Public Class Form1
Form1.ListBox1.DataSource = formTitles
End Sub

Private Delegate Function GetFormTitleDelegate(ByVal f As Form) As String
Private Function GetFormTitle(ByVal f As Form) As String
Private Delegate Function GetFormTitleDelegate(f As Form) As String
Private Function GetFormTitle(f As Form) As String
' Check if the form can be accessed from the current thread.
If Not f.InvokeRequired Then
' Access the form directly.
Expand Down Expand Up @@ -161,7 +161,7 @@ Public Class Form1
End Class

' This is called by snippet 9, the NetworkAvailabiliyChanges event.
Public Sub SetConnectionStatus(ByVal x As Boolean)
Public Sub SetConnectionStatus(x As Boolean)
MsgBox("Network: " & x)
End Sub

Expand Down Expand Up @@ -291,13 +291,13 @@ Public Class Form1

Dim Label1 As New Label
' <snippet50>
Private Sub DisplayAvailability(ByVal available As Boolean)
Private Sub DisplayAvailability(available As Boolean)
Label1.Text = available.ToString
End Sub

Private Sub MyComputerNetwork_NetworkAvailabilityChanged(
ByVal sender As Object,
ByVal e As Devices.NetworkAvailableEventArgs)
Private Sub MyComputerNetwork_NetworkAvailabilityChanged(
sender As Object,
e As Devices.NetworkAvailableEventArgs)

DisplayAvailability(e.IsNetworkAvailable)
End Sub
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
System.Reflection.BindingFlags.NonPublic Or _
System.Reflection.BindingFlags.Instance

Shared Function InstantiateIt(ByVal t As Type, ByVal ParamArray args() As Object) As Object
Shared Function InstantiateIt(t As Type, ParamArray args() As Object) As Object
Try
Dim ret As Object = t.InvokeMember(Nothing, _
bf Or System.Reflection.BindingFlags.CreateInstance, _
Dim ret As Object = t.InvokeMember(Nothing,
bf Or System.Reflection.BindingFlags.CreateInstance,
Nothing, Nothing, args)
Return ret
Catch ex As Exception
Expand All @@ -17,10 +17,10 @@
End Try
End Function

Shared Function InvokeMethod(ByVal obj As Object, ByVal method As String, ByVal ParamArray args() As Object) As Object
Shared Function InvokeMethod(obj As Object, method As String, ParamArray args() As Object) As Object
Try
Dim ret As Object = obj.GetType.InvokeMember(method, _
bf Or System.Reflection.BindingFlags.InvokeMethod, _
Dim ret As Object = obj.GetType.InvokeMember(method,
bf Or System.Reflection.BindingFlags.InvokeMethod,
Nothing, obj, args)
Return ret
Catch ex As Exception
Expand All @@ -29,28 +29,28 @@
End Try
End Function

Shared Function GetProperty(ByVal obj As Object, ByVal method As String, ByVal ParamArray args() As Object) As Object
Dim ret As Object = obj.GetType.InvokeMember(method, _
bf Or System.Reflection.BindingFlags.GetProperty, _
Shared Function GetProperty(obj As Object, method As String, ParamArray args() As Object) As Object
Dim ret As Object = obj.GetType.InvokeMember(method,
bf Or System.Reflection.BindingFlags.GetProperty,
Nothing, obj, args)
Return ret
End Function

Shared Function GetField(ByVal obj As Object, ByVal field As String) As Object
Dim ret As Object = obj.GetType.InvokeMember(field, _
bf Or System.Reflection.BindingFlags.GetField, _
Shared Function GetField(obj As Object, field As String) As Object
Dim ret As Object = obj.GetType.InvokeMember(field,
bf Or System.Reflection.BindingFlags.GetField,
Nothing, obj, Nothing)
Return ret
End Function

Shared Function ListMembers(ByVal obj As Object) As String
Shared Function ListMembers(obj As Object) As String
Dim ret As String = ""
For Each m As System.Reflection.MemberInfo In obj.GetType.GetMembers(bf)
ret &= m.Name & " " & m.ToString & vbCrLf
Next
Return ret
End Function
Shared Function GetProperties(ByVal obj As Object) As String
Shared Function GetProperties(obj As Object) As String
Dim ret As String = "type = " & obj.GetType.ToString & vbCrLf

For Each m As System.Reflection.PropertyInfo In obj.GetType.GetProperties(bf Or Reflection.BindingFlags.GetProperty)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
' of the Project Designer ("Properties" under the "Project" menu).


Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Private Sub SplashScreen1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Set up the dialog text at runtime according to the application's assembly information.

'TODO: Customize the application's assembly information in the "Application" pane of the project
Expand Down Expand Up @@ -36,7 +36,7 @@
Get
Return TextBox1.Text
End Get
Set(ByVal value As String)
Set(value As String)
TextBox1.Text = value
Me.Refresh()
End Set
Expand Down

This file was deleted.

Loading

0 comments on commit a84ae9a

Please sign in to comment.