4 Replies - 466 Views - Last Post: 07 December 2010 - 11:54 AM Rate Topic: ***** 1 Votes

#1 monkeyB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-December 10

Im looking for a command, like a.... GROUP!

Posted 05 December 2010 - 03:55 PM

Hi,
Im pretty new to vb
im looking for a command like group.
what i wanted to is

if (something)* have A and B
then ..
else ..


*=something supposed to have more than one value(letter/number)

Are there such a thing ?
Is This A Good Question/Topic? 0
  • +

Replies To: Im looking for a command, like a.... GROUP!

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Im looking for a command, like a.... GROUP!

Posted 05 December 2010 - 04:40 PM

Give us an example of what you're comparing in the IF statement.

You can use something like this for a MyVariable of type String

Suppose myVariable holds the string "CHARLIE"
If MyVariable.Contains("A"c) OR myVariable.Contains("B") Then
  ...whatever you want to do
End If

This will return a true result as myVariable will contain the character "A" and will there for process the code inside the If...End If block.

Otherwise, could you clarify a little better as to what you're wanting to achieve.

This post has been edited by CharlieMay: 05 December 2010 - 04:40 PM

Was This Post Helpful? 1
  • +
  • -

#3 monkeyB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-December 10

Re: Im looking for a command, like a.... GROUP!

Posted 06 December 2010 - 02:14 AM

View PostCharlieMay, on 05 December 2010 - 03:40 PM, said:

Give us an example of what you're comparing in the IF statement.

You can use something like this for a MyVariable of type String

Suppose myVariable holds the string "CHARLIE"
If MyVariable.Contains("A"c) OR myVariable.Contains("B") Then
  ...whatever you want to do
End If

This will return a true result as myVariable will contain the character "A" and will there for process the code inside the If...End If block.

Otherwise, could you clarify a little better as to what you're wanting to achieve.

Great!
Can you tell me how can i change second/third letters of string variable, please ?

This post has been edited by monkeyB: 06 December 2010 - 02:14 AM

Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Im looking for a command, like a.... GROUP!

Posted 06 December 2010 - 07:39 AM

One way you could do it would be to convert the string .ToCharArray and then build it back together skipping over the append if the array index = 1 or 2

Another way would be to build a new string off the .substring(0,1) and append the .substring(3) of the original string. This one requiring a lot less code.

There are two methods which should give you enough information to research a solution. Then if you get stuck you can post your attempt and we can help you further.
Was This Post Helpful? 1
  • +
  • -

#5 monkeyB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-December 10

Re: Im looking for a command, like a.... GROUP!

Posted 07 December 2010 - 11:54 AM

View PostCharlieMay, on 06 December 2010 - 06:39 AM, said:

One way you could do it would be to convert the string .ToCharArray and then build it back together skipping over the append if the array index = 1 or 2

Another way would be to build a new string off the .substring(0,1) and append the .substring(3) of the original string. This one requiring a lot less code.

There are two methods which should give you enough information to research a solution. Then if you get stuck you can post your attempt and we can help you further.

I get second way to work, THANKS.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1