locked
What is the C# Equivalent for the following vb6 code? RRS feed

  • Question

  •  OneModul.Name = Left(Modulname, InStr(1, Modulname, vbNullChar, vbBinaryCompare) - 1)
    Wednesday, April 24, 2013 5:56 AM

Answers

  • OneModul.Name = Modulname.Substring(1, Modulname.IndexOf("\0", 1, StringComparison.InvariantCulture));


    It all Happenz Sendil

    • Proposed as answer by Mike Feng Friday, April 26, 2013 12:27 PM
    • Marked as answer by Mike Feng Thursday, May 2, 2013 2:35 PM
    Wednesday, April 24, 2013 9:00 AM
  • Note that the VB string functions are 1-based, so you need to adjust those indices:

    OneModul.Name = Modulname.Substring(0, Modulname.IndexOf("\0"));


    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

    • Proposed as answer by Mike Feng Friday, April 26, 2013 12:28 PM
    • Marked as answer by Mike Feng Thursday, May 2, 2013 2:35 PM
    Wednesday, April 24, 2013 2:07 PM

All replies

  • OneModul.Name = Modulname.Substring(1, Modulname.IndexOf("\0", 1, StringComparison.InvariantCulture));


    It all Happenz Sendil

    • Proposed as answer by Mike Feng Friday, April 26, 2013 12:27 PM
    • Marked as answer by Mike Feng Thursday, May 2, 2013 2:35 PM
    Wednesday, April 24, 2013 9:00 AM
  • Note that the VB string functions are 1-based, so you need to adjust those indices:

    OneModul.Name = Modulname.Substring(0, Modulname.IndexOf("\0"));


    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

    • Proposed as answer by Mike Feng Friday, April 26, 2013 12:28 PM
    • Marked as answer by Mike Feng Thursday, May 2, 2013 2:35 PM
    Wednesday, April 24, 2013 2:07 PM