vbcrlf,vbnewline,vbcr לא עובדים....

itaisass

New member
vbcrlf,vbnewline,vbcr לא עובדים....

יש לי vb6 על XP ואני מנסה ליישם את הקוד הבא: הרעיון הוא שאני רוצה לשלוף מקובץ הטקסט את השורות הרלוונטיות לי למשל יש לי בקובץ את השורות הבאות: """"""""""""""""""""""""""""""""""""""""""תחילת טקסט"""""""""""""""""" Trying to read the drive IDs using physical access with admin rights Primary Controller - Master drive Drive Model Number________________: WDC WD800BB-75JHC0 Drive Serial Number_______________: WD-WMAM9T735526 Drive Controller Revision Number__: 06.01C06 Controller Buffer Size on Drive___: 2097152 bytes Drive Type________________________: Fixed Drive Size________________________: 80000000000 bytes Primary Controller - Slave drive Drive Model Number________________: M-Systems IDE 4000 V1.13 Drive Serial Number_______________: 999999999 Drive Controller Revision Number__: 060726 Controller Buffer Size on Drive___: 512 bytes Drive Type________________________: Fixed Drive Size________________________: 523837440 bytes """""""""""""""""""""""""""""""""""""""""סוףהטקסט"""""""""""""""""""""""""""""""""""""" ואני רוצה לשלוף רק את השורות הבאות: Drive Model Number________________: M-Systems IDE 4000 V1.13 Drive Serial Number_______________: 999999999 Drive Controller Revision Number__: 060726 Controller Buffer Size on Drive___: 512 bytes Drive Type________________________: Fixed Drive Size________________________: 523837440 bytes """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" זאת התוכנית הלא גמורה שלי: Private Sub Form_Load() 'Shell ("cmd /k c:\diskid32.exe >> c:\diskid32.txt") Call SplitDataSourceToFile End Sub Public Function SplitDataSourceToFile() Dim FullPathToTxtFile As String Dim startRow As Integer Dim RowNumber As Integer Dim LnTmp1 As String Dim WriteLineNumber As Integer Dim WriteLineNumberFlag As Boolean 'Dim strSplitBatchFile() As String Dim strSupplierBatchFile() As String Dim srtBatchfile As String Dim strTmp As String Dim lineCounter As Integer Dim EOL As String EOL = Chr(13) + Chr(10) Dim strfilename strfilename = "c:\diskid32_4000.txt" 'Reading All File to string FullPathToTxtFile = strfilename Open strfilename For Input As #2 srtBatchfile = Input(LOF(2), #2) Close #2 strSplitBatchFile = Split(srtBatchfile, "Secondary Controller - Master drive") For lineCounter = LBound(strSplitBatchFile) + 1 To UBound(strSplitBatchFile) Text1.Text = Text1.Text & strSplitBatchFile(i) & vbCrLf Next lineCounter End Function
 

טרמפיסט

New member
כמה הערות

* בפעם הבאה ישר את הקוד שלך לפי תגי "קוד" ו-"סקוד", כך הוא יהיה הרבה יותר מובן ופחות אנשים יסגרו את ההודעה שלך כלעומת שפתחו אותה. * הוסף אחרי פקודת ה-Shell את פקודת DoEvents כדי לתת שהות למחשב לעבד ולכתוב לקובץ. נדמה שהמחשב לא מספיק לעשות זאת ואתה מנסה לקרוא מהקובץ עוד לפני שהמחשב הספיק לכתוב לתוכו משהו. * לדעתי ה-Delimiter שלך בפקודת ה-Split אינו קיים בכלל בטקסט (המחרוזת לפיה אתה "חותך" את הטקסט). * במקום לקרוא את כל הקובץ למשתנה ולחתוך אותו, נסה לקרוא אותו שורה אחר שורה ולהתייחס רק לחלק שמופיע אחרי נקודת החילוק. לדוגמה:
Const DELIMITER As String = "Primary Controller - Slave drive" Dim sFileName As String Dim iFileNumber As Integer Dim sFileLine As String Dim bPastDelimiter As Boolean sFileName = "blablabla.txt" iFileNumber = FreeFile Open sFileName For Input As #iFileNumber While Not EOF(iFileNumber) Line Input #iFileNumber, FileLine If bPastDelimiter Then 'do whatever you want with the data you got End If If (FileLine = DELIMITER) Then bPastDelimiter = True Wend Close #iFileNumber​
בהצלחה.
 

itaisass

New member
אוקיי תודה על ההתייחסות ולהבא אעשה מה שכתבת

אני מסתבך עם הפיתרון לזה כבר 3 שבועות ולא יוצא ממנו כנראה שאני לא חושב כמו שצריך יש לך רעיון איך אני אמור לפתור זאת?
 

itaisass

New member
היי טרמפיסט אני רוצה לבצע:

את טקסט הזה Drive Model Number________________ להכניס למשתנה כלשהו ואת הטקסט הזה M-Systems IDE 4000 V1.13 להכניס למשתנה אחר וכך הלאה לגבי שאר שורות הטקסט יש לך רעיון איך לבצע זאת? תודה
 

טרמפיסט

New member
זה פורום; לא צ'אט

אי אפשר לצפות לתשובה תוך דקות. ולעניינינו: לא ציינת *מה* בדיוק לא עובד ומתי הוא לא עובד. לא ציינת מה בכל זאת קורה ומה לא בסדר בזה. לא ציינת את ההבדל בין הרצוי למצוי. אנא, הייה יותר ענייני בשאלותיך כדי שתיאפשר לנו לעזור לך.
 
למעלה