| Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате |
| Форум программистов > VB6 > Строка от CommonDialog(как разделить на части...) |
| Автор: Farhod 31.8.2002, 01:05 |
| Я сделал свойство CommonDialog таким что бы при вызове окна "Oткрытия файлов" ShowOpen" он открывал (выделял) несколько файлов.И в результате у меня в строке "Имя файла" получается несколько имен файлов разделённые с кавычками. Я хочу сделать так что бы при открытии этих файлов каждый файл добавлялся в ListBox. У меня в свойсве FileName получается несколько файлов. Подскажите ... |
| Автор: Win MK 32 31.8.2002, 05:57 |
| Отлавливай с помощью функции mid() то что между кавычками и добавляй в список. |
| Автор: Win MK 32 31.8.2002, 05:57 |
| mid(переменная_с_открытыми_файлами, начальный_символ, количество_символов_после_начального) |
| Автор: Farhod 1.9.2002, 00:31 |
| Да но как программно определить кавычки ? |
| Автор: Win MK 32 1.9.2002, 05:25 | ||
text2.text :
Перебирай с помощью mid() по одному символу и если он не равен text2.text то переменная1 = переменная1 + этот_символ иначе добавляй "переменная1" в список и переменная1 = "" |
| Автор: Sniper 21.1.2003, 06:55 |
| FarhodFarhodFarhod |
| Автор: cardinal 21.1.2003, 07:09 |
| Split Function Description Returns a zero-based, one-dimensionalarray containing a specified number of substrings. Syntax Split(expression[, delimiter[, count[, compare]]]) The Split function syntax has these parts: Part Description expression Required.String expression containing substrings and delimiters. If expression is a zero-length string(""), Split returns an empty array, that is, an array with no elements and no data. delimiter Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned. count Optional. Number of substrings to be returned; –1 indicates that all substrings are returned. compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. Settings The compare argument can have the following values: Constant Value Description vbUseCompareOption –1 Performs a comparison using the setting of the Option Compare statement. vbBinaryCompare 0 Performs a binary comparison. vbTextCompare 1 Performs a textual comparison. vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database. |
| Автор: Роман 1.7.2005, 13:29 |
| 'Быть может "тупорыльно", но работает!!! inull = False spath = CommonDialog1.FileName n = 0 m = Len(spath) - 1 Dim mf() As String ' массив файлов If Mid(spath, Len(spath), 1) = Chr(0) Then spath = Mid(spath, 1, Len(spath) - 1) Do While inull = False i = InStrRev(spath, vbNullChar) If i = 0 Then inull = True Else tmp = Mid(spath, i + 1, Len(spath) - i) If i = Len(spath) Then ReDim Preserve mf(0): mf(0) = tmp temp = Mid(spath, i + 1, Len(spath) - i) If i <> 0 Then spath = Mid(spath, 1, i - 1) If temp <> "" Then ReDim Preserve mf(n + 1): mf(n) = temp: n = n + 1 Loop If n = 1 Then n = 2 ' типа если был 1 файл, то 2, т.к. первое значение - путь For i = 0 To n - 2 MsgBox mf(i) Next i ' получили как вы поняли массив mf () от 0 до n-2 |
| Автор: ~FoX~ 1.7.2005, 13:51 |
| split возвращает массив стрингов. |
| Автор: Vach 1.7.2005, 14:41 | ||
| Роман используй теги кода. Пример с использованием Split Function
|
| Автор: Naghual 1.7.2005, 17:52 |
| А по моему проще будет разобратся с кавычками через Replace? |