5 Replies - 521 Views - Last Post: 31 January 2013 - 04:02 PM Rate Topic: -----

#1 xilith117  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 72
  • Joined: 13-August 11

Get Character on Both Sides of Delineator

Posted 26 January 2013 - 10:39 AM

I am working on an algebra calculator. I want to be able to get each of the Characters on either side of the delineator saved as strings.

Example: 5x=2*63
string 1 = x
string 2 = 2.
THANKS. :)/>


Below i have the code for splitting the problem at the equals sign.
  Dim chars As String() = TextBox1.Text.Split(New Char() {"="c})


Is This A Good Question/Topic? 0
  • +

Replies To: Get Character on Both Sides of Delineator

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9587
  • View blog
  • Posts: 36,326
  • Joined: 12-June 08

Re: Get Character on Both Sides of Delineator

Posted 26 January 2013 - 11:46 AM

You are using it wrong..

Dim foo As String = "5x=2*63"
Dim bar() As String = foo.Split("=")

Was This Post Helpful? 1
  • +
  • -

#3 xilith117  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 72
  • Joined: 13-August 11

Re: Get Character on Both Sides of Delineator

Posted 31 January 2013 - 02:07 PM

Ok. I guess my code is
Dim whole As String = "5x=2*63"
Dim chars() As String = whole.Split("=")

but tha still doesnt give me a "x" string and a "2" string... Thanks.

This post has been edited by xilith117: 31 January 2013 - 02:08 PM

Was This Post Helpful? 0
  • +
  • -

#4 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,535
  • Joined: 11-May 12

Re: Get Character on Both Sides of Delineator

Posted 31 January 2013 - 02:18 PM

View Postxilith117, on 31 January 2013 - 04:07 PM, said:

Ok. I guess my code is
Dim whole As String = "5x=2*63"
Dim chars() As String = whole.Split("=")

but tha still doesnt give me a "x" string and a "2" string... Thanks.


Try This

        Dim whole As String = "5x=2*63"
        ' left character
        Dim string1 As String = whole.Substring(whole.IndexOf("=") - 1, 1)
        ' right character
        Dim string2 As String = whole.Substring(whole.IndexOf("=") + 1, 1)


This post has been edited by ybadragon: 31 January 2013 - 02:30 PM

Was This Post Helpful? 1
  • +
  • -

#5 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Get Character on Both Sides of Delineator

Posted 31 January 2013 - 02:26 PM

View Postxilith117, on 31 January 2013 - 03:07 PM, said:

Ok. I guess my code is
Dim whole As String = "5x=2*63"
Dim chars() As String = whole.Split("=")


but tha still doesnt give me a "x" string and a "2" string... Thanks.

        Dim whole As String = "5x=2*63"
        Dim chars() As String = whole.Split(CChar("="))
        Dim leftChar As Char = CChar(chars(0).Substring(chars(0).Length - 1))
        Dim rightchar As Char = CChar(chars(1).Substring(0, 1))


Bear in mind that I am just answering your question as stated, and it may not be suitable for what you REALLY want to do.
Was This Post Helpful? 1
  • +
  • -

#6 xilith117  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 72
  • Joined: 13-August 11

Re: Get Character on Both Sides of Delineator

Posted 31 January 2013 - 04:02 PM

Quote

Bear in mind that I am just answering your question as stated, and it may not be suitable for what you REALLY want to do.
My question isn't what I REALLY want to do, just close enough for me figure out what to do. I wouldn't want you guys to ruin ALL of my fun. :tt2: I will try these examples and let you guys know if I have any more questions. :) thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1