如何在输入的字符串中找出特定的字母,如d,g,i,m,然后显示出来?

sandywing 2003-03-19 12:13:50
如何在输入的字符串中找出特定的字母,如d,g,i,m,然后显示出来?
...全文
194 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandywing 2003-03-20
  • 打赏
  • 举报
回复
写错了Next的顺序
Sub Search()
Dim str1 as string
dim str2 as string
dim i as integer
dim temp as string
dim j as integer
dim compare as integer
str1=text1.text
str2="dgim"
for i = 1 to len(str1)
for j = 1 to len(str2)
compare = instr(1,mid(str1,i,1),Mid(str2,j,1),vbTextCompare)
if compare <> 0 then
temp = temp & mid(str1,i,1)
end if
next j
~~~
next i
~~~
text2.text=temp
end sub
sandywing 2003-03-20
  • 打赏
  • 举报
回复
Sub Search()
Dim str1 as string
dim str2 as string
dim i as integer
dim temp as string
dim j as integer
dim compare as integer
str1=text1.text
str2="dgim"
for i = 1 to len(str1)
for j = 1 to len(str2)
compare = instr(1,mid(str1,i,1),Mid(str2,j,1),vbTextCompare)
if compare <> 0 then
temp = temp & mid(str1,i,1)
end if
next i
next j
text2.text=temp
end sub
用户 昵称 2003-03-19
  • 打赏
  • 举报
回复
找位置吧。
northwolves 2003-03-19
  • 打赏
  • 举报
回复
不明白你的意思
lxcc 2003-03-19
  • 打赏
  • 举报
回复
instr函数
InStr([start, ]string1, string2[, compare])
lye 2003-03-19
  • 打赏
  • 举报
回复
instr只能找出第一个位置,
我觉的用mid$结合for循环.
vcbug 2003-03-19
  • 打赏
  • 举报
回复
你是的意思是发现字符串里有需要找的字母,就显示找到的,是吗 ?

那就用instr一个一个判断,
山顶洞人-平 2003-03-19
  • 打赏
  • 举报
回复
同意楼上的
minajo21 2003-03-19
  • 打赏
  • 举报
回复
InStr函数可以找出他们的位置
yanzeyuan 2003-03-19
  • 打赏
  • 举报
回复
不明白你是什么意思!
如果你是在输入的过程中把d g i m等显示出来就在text的change事件中
用char(keycode)和'd'作比较

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧