Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. String Literal in VB.NET?

String Literal in VB.NET?

Scheduled Pinned Locked Moved Visual Basic
csharpregexvisual-studiogame-dev
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    afronaut
    wrote on last edited by
    #1

    hey all, I'm trying to do a very simple regular expression but VS.NET is barking at a simple line of code. At the top I have: Imports System.Text.RegularExpressions And in my code I have: Dim r As Regex() r = New Regex("\d{2}[a-zA-Z]+", RegexOptions.IgnoreCase Or RegexOptions.Compiled) The error message is: C:\DavidCode\NETBeast\WindowsApplication2\Form1.vb(74): Value of type 'System.Text.RegularExpressions.Regex' cannot be converted to '1-dimensional array of System.Text.RegularExpressions.Regex'. I'm not sure I understand why except that my regex may not be a string literal. In C# I can just do @"..." but in VB.NET it isn't working.. :eek: *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

    P 1 Reply Last reply
    0
    • A afronaut

      hey all, I'm trying to do a very simple regular expression but VS.NET is barking at a simple line of code. At the top I have: Imports System.Text.RegularExpressions And in my code I have: Dim r As Regex() r = New Regex("\d{2}[a-zA-Z]+", RegexOptions.IgnoreCase Or RegexOptions.Compiled) The error message is: C:\DavidCode\NETBeast\WindowsApplication2\Form1.vb(74): Value of type 'System.Text.RegularExpressions.Regex' cannot be converted to '1-dimensional array of System.Text.RegularExpressions.Regex'. I'm not sure I understand why except that my regex may not be a string literal. In C# I can just do @"..." but in VB.NET it isn't working.. :eek: *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      It's because of those parentheses after Dim r As Regex. What you're saying here is "give me an array of Regexes" then you're saying assign this new Regex to this array variable which just isn't possible. Paul

      A 1 Reply Last reply
      0
      • P Paul Riley

        It's because of those parentheses after Dim r As Regex. What you're saying here is "give me an array of Regexes" then you're saying assign this new Regex to this array variable which just isn't possible. Paul

        A Offline
        A Offline
        afronaut
        wrote on last edited by
        #3

        Thanks Paul... Brain Fart; I keep writing things as: Regex r = new Regex("..") and then remembering I'm in vb.net and not adjusting properly - :) *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups