Sign in to follow this  
Followers 0
datatek

StringInStr StringSplit

4 posts in this topic

$voller_name = ($vorname & " " & $nachname)
$Name_conv = StringLower(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($voller_name,"ü","ue"),"ö","oe"),"ä","ae"),"ß","ss"),"Ü","Ue"),"Ö","Oe"),"Ä","Ae"))

If StringInStr($Name_split[$Name_split[0]], '-') Then
    $var = StringSplit($Name_split[$Name_split[0]], '-')
    $Name_split[$Name_split[0]] = $var[$var[0]]
EndIf
$bname = StringLeft($Name_split[1], 1) & "." & $Name_split[$Name_split[0]]

In the above code first name and surname are split and, if there is a hypen in the name, the second part selected for $bname.

I need to have the first part before the hypen, instead of the second.

Could someone help?

Share this post


Link to post
Share on other sites



Would you mind giving an example output? Your code seems a bit...messy. What exactly are you trying to do by the way? There may be an easier way to do it.

Share this post


Link to post
Share on other sites

Would you mind giving an example output? Your code seems a bit...messy. What exactly are you trying to do by the way? There may be an easier way to do it.

If I put in the name "Sam Adams", the output is s.adams (this is also what I want).

If I put in the name "John Smith-Weston", the output is j.weston, but I want j.smith (the part before the -, not the part after it).

The relevant part of the code is

If StringInStr($Name_split[$Name_split[0]], '-') Then
    $var = StringSplit($Name_split[$Name_split[0]], '-')
    $Name_split[$Name_split[0]] = $var[$var[0]]
EndIf

Share this post


Link to post
Share on other sites

Full working code. Short,simple, to the point

$name = InputBox("Name","Enter your name","")

If StringInStr($name,"-") Then
    $split = StringSplit($name,"-")
    $newname = StringSplit($split[1]," ")
    $out = StringLeft($newname[1],1) & "." & $newname[2]
EndIf

MsgBox(0,"",$out)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0