Skip to content

Instantly share code, notes, and snippets.

View bervukas's full-sized avatar

Bernard Vukas bervukas

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bervukas on github.
  • I am bvukas (https://keybase.io/bvukas) on keybase.
  • I have a public key ASCP4a7mtsGfbozAVML6c0ycUCMThqd4-OF-uH4jhXfstwo

To claim this, I am signing this object:

@bervukas
bervukas / ExcelVBAUnitTest.vb
Last active May 27, 2019 23:57
Tutorial: Excel Unit Testing with VBA
Option Explicit
''
' Validate the password length so that it's between 8-16 characters long
'
' Returns:
'
' TRUE - Password matches the lenght requirement
' FALSE - Password doesn't match the length requirement

Keybase proof

I hereby claim:

  • I am bervukas on github.
  • I am bvukas (https://keybase.io/bvukas) on keybase.
  • I have a public key ASAOi3k7ofi2YVwvQXPTF1GSA6atPVG1_eI_j11K5AJXOwo

To claim this, I am signing this object:

Option Explicit
Option Private Module
'@TestModule
'@Folder("Tests")
Private Assert As Object
'@ModuleInitialize
Public Sub ModuleInitialize()
'@TestMethod
Public Sub TestMethod1() 'TODO Rename test
On Error GoTo TestFail
'Arrange:
'Act:
'Assert:
Assert.Inconclusive
@bervukas
bervukas / ExcelCodedUIDemo.cs
Last active December 23, 2016 05:39
Sample snippet used in Coded UI Test for an Excel COM add-in
// Launch Excel 2016 from '%ProgramFiles%\Microsoft Office\root\Office16\EXCEL.EXE'
ApplicationUnderTest excelApp = ApplicationUnderTest.Launch(this.StartAndQuitExcelParams.ExePath, this.StartAndQuitExcelParams.AlternateExePath);
// After Excel loads, click the 'Blank workbook' list item
Mouse.Click(blankWorkbookListItem, new Point(117, 182));
// Select your add-in's ribbon tab
Mouse.Click(myAddinRibbonTab, new Point(276, 771));
// Click a control on your add-in's ribbon, in order to display the VBA userform
@bervukas
bervukas / EmptyTestMethod.vb
Created May 4, 2016 15:44
Empty Test Method in Rubberduck VBA
'@TestMethod
Public Sub TestMethod1() 'TODO: Rename test
On Error GoTo TestFail
'Arrange:
'Act:
'Assert:
Assert.Inconclusive
@bervukas
bervukas / HungarianFixed.vb
Last active March 1, 2016 12:28
How to fix Hungarian notation
Function CalculateTotal(productId As String,
quantity As Integer,
unitPrice As Double) As Double
''''
' etc.
End Function
@bervukas
bervukas / IncorrectVariableDeclaration.vb
Last active March 1, 2016 11:47
Declaring variables on a single line in VBA
Sub CalculatePayroll()
Dim a, b, c, d As Integer '' Incorrect
'' Do this instead:
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
@bervukas
bervukas / VariableNames.vb
Last active March 1, 2016 11:27
VBA Example: Variable Names
Sub Test()
Dim data As String
Dim data2 As Integer
Dim foo As Boolean
Dim wph As Integer
Dim dummy as Long
''
' etc.
End Sub