Public Class Form1
Private Sub cmdStart1_Click(sender As System.Object, e As System.EventArgs) Handles cmdStart1.Click
lblShowResult1.Text = ""
For a% = 1 To lblText1.Text.Length
If Mid(lblText1.Text, a, 1) = ":" Then
For b% = a + 1 To lblText1.Text.Length
If Mid(lblText1.Text, b, 1) = ":" Then Exit Sub
lblShowResult1.Text += Mid(lblText1.Text, b, 1)
Next
End If
Next
End Sub
Private Sub cmdStart2_Click(sender As System.Object, e As System.EventArgs) Handles cmdStart2.Click
lblShowResult2.Text = ""
For a% = 1 To lblText2.Text.Length
If Mid(lblText2.Text, a, 1) = ":" Then
For b% = a + 1 To lblText2.Text.Length
If Mid(lblText2.Text, b, 1) = ":" Then Exit Sub
lblShowResult2.Text += Mid(lblText2.Text, b, 1)
Next
End If
Next
End Sub
End Class
перевести на basic
ЗАДАНИЕ 4 НА PASCAL
program Prog2;
uses Crt;
procedure StrCpyCh(var dest: string; src: string; delim: char);
var
p: integer;
temp: string;
begin
p := Pos(delim, src);
if p = 0 then dest := src else
begin
temp := Copy(src, p+1, Length(src)-p);
p := Pos(delim, temp);
if p = 0 then dest := temp else dest := Copy(temp, 1, p-1);
end;
end;
var
s: string;
begin
ClrScr;
StrCpyCh(s, 'Today day dark: animals - sheep, cat, tiger: fox !', ':');
WriteLn(s);
ReadLn;
end.
ЗАДАНИЕ 4 НА С
#include <stdio.h>
char* ch_strcpy(char* dst, const char* src, char ch) {
char* iter = dst;
while( *src ) {
if( *src++ == ch )
break;
}
while( *src != '\0' && *src != ch) {
*iter = *src++;
++iter;
}
*iter = '\0';
return dst;
}
int main(void)
{
char str[128];
ch_strcpy(str, "Today day dark: animals - sheep, cat, tiger: fox !", ':');
puts(str);
getchar();
return 0;
}
Ваша задача элементарно решается с помощью функций [color=blue]Split()[/color] и [color=blue]MsgBox()[/color].
Код VB2010