String2Array(sInputFormat,m_arrType,';'); 或者是:
int SplitString(CString & str,TCHAR cTok,CStringArray& aryItem) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// VC下的Split函数熟悉VB代码的朋友应该都极度喜欢Split函数,因为实在太方便了,自动帮你把字符串按照要求拆分,在VC++中微软隐藏了一个函数,其功效等同与VB中的SPLIT函数,该函数原型如下: BOOL AfxExtractSubString(CString& rString,LPCTSTR lpszFullString,int iSubString,TCHAR chSep = '/n') 参数说明: rString 得到的字符串;lpszFullString 待分割的字符串;iSubString 要得到第几个字符串;chSep 个子串之间的分隔符,默认是回车; 返回值为Flase表示iSubString 越界,否则分隔成功 例如,有一个字符串strFullString = "abcd-hgdy-weiuiwu-sdlsk";则有: CString strTmp; AfxExtractSubString( strTmp,(LPCTSTR)strFullString,'-');//strTmp的内容为abcd AfxExtractSubString( strTmp,2,'-');//strTmp的内容为weiuiwu 感觉蛮好用的,但是有两个限制: 1.仅仅能在MFC下使用的函数 2.分隔只能使用字符,不能使用字符串。 |
原文地址:https://www.jb51.cc/vb/262694.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。