Advertisement
Guest User

Detect if VBA module has content

a guest
Sep 24th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.74 KB | None | 0 0
  1.     let hasContent lines =
  2.         let mutable inBlock = false
  3.         let isContent line =
  4.             let startsWith input word =
  5.                 Regex.Match(input, @"^\s*" + word,
  6.                     RegexOptions.CultureInvariant ||| RegexOptions.IgnoreCase).Success
  7.             match (line:string) with
  8.             | _ when line.Trim().Length = 0 -> false
  9.             | s when startsWith s "Version" -> false
  10.             | s when startsWith s "Attribute" -> false
  11.             | s when startsWith s "Begin" ->
  12.                 inBlock <- true
  13.                 false
  14.             | s when inBlock && startsWith s "End" ->
  15.                 inBlock <- false
  16.                 false
  17.             | _ -> not inBlock
  18.         Seq.exists isContent lines
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement