23 lines
558 B
Text
23 lines
558 B
Text
dim as string s, nxt
|
|
|
|
input "Enter string: ", s
|
|
|
|
if len(s)<2 then 'A string with one or zero characters passes by default
|
|
print "All characters are the same."
|
|
end
|
|
end if
|
|
|
|
dim as ubyte i
|
|
|
|
for i = 1 to len(s)-1
|
|
nxt = mid(s, i+1, 1)
|
|
if mid(s, i, 1)<>nxt then 'if any character differs from the previous one
|
|
print "First non-matching char is "+nxt
|
|
print "It occurs at position "+str(i+1)
|
|
print "Its hex value is "+hex(asc(nxt))
|
|
end
|
|
end if
|
|
next i
|
|
|
|
'otherwise, success!
|
|
print "All characters are the same."
|