Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 25th, 2006, 06:31 PM
ehsanking ehsanking is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 207 ehsanking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 3 m 51 sec
Reputation Power: 4
Arrow How to extract certain data patterns from textbox input?

Hi all .i got the following inside a textbox inside my form. I am looking for a way to ripp the song path and title from it and use them and insert them to mysql datbase. But i do not know how to ripp those part
i be happy that an expert tell me how i can do it using vb6. The number of song path are not know in before and the parts
that i want to write to mysql are shown in bold.Thanks


data inside my texbox:
Code:
<?xml version="1.0" encoding="UTF-8" ?> 
- <player showDisplay="yes" showPlaylist="yes" autoStart="yes">
  <song path="http://www.mysite.com/TtdlI3l1lIl0OOO0a/singer1/album1/song1.mp3" title="song title" /> 
  <song path="http://www.mysite.com/TtdlI3l1lIl0OOO0a/singer1/album1/songname2.mp3" title="song title 2" /> 
  
  </player>

Reply With Quote
  #2  
Old May 12th, 2006, 06:26 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 36 m 35 sec
Reputation Power: 1243
Quote:
Originally Posted by ehsanking
data inside my texbox:
Code:
<?xml version="1.0" encoding="UTF-8" ?> 
- <player showDisplay="yes" showPlaylist="yes" autoStart="yes">
  <song path="http://www.mysite.com/TtdlI3l1lIl0OOO0a/singer1/album1/song1.mp3" title="song title" /> 
  <song path="http://www.mysite.com/TtdlI3l1lIl0OOO0a/singer1/album1/songname2.mp3" title="song title 2" /> 
  
  </player>


Hi,

The following code demonstrates how you can do this, it assumes that you have a command button on your form (Command1) and that, although you may have lots of songs in the string they are always in the same format, i.e. song path first:

Code:
Dim pos As Integer
Dim string1 As String
Dim string2 As String
Dim songtitlearray() As String
Dim songpatharray() As String
Dim counter As Integer

Private Sub Command1_Click()
    counter = 0
    ReDim songpatharray(1)
    ReDim songtitlearray(1)
    string1 = Text1.Text
    If InStr(1, string1, "song path=") Then
        While InStr(1, string1, "song path=")
            string2 = ""
            pos = InStr(1, string1, "song path=")
            string1 = Mid$(string1, pos + 11)
            string2 = Left$(string1, InStr(1, string1, "title") - 3)
            If counter > 1 Then
                ReDim Preserve songtitlearray(counter)
                ReDim Preserve songpatharray(counter)
            End If
            songtitlearray(counter) = string2
            string1 = Mid$(string1, InStr(1, string1, "title") + 7)
            string2 = Left$(string1, InStr(1, string1, "/") - 3)
            string1 = Mid$(string1, InStr(1, string1, "/"))
            songpatharray(counter) = string2
            counter = counter + 1
        Wend
    End If
End Sub


This works by reading the information from your textbox (un-imaginatively called Text1 in my example!!!) and storing it in a variable called string1. The program will loop while string1 still contains the string "song path=", meaning that there is still data to extract. On each iteration, the program moves through the string extracting just the bits between the double quotes, string1 is cut down each time ensuring that the program does not go into a continuous loop!!

When the program has finished, the results should be held in two arrays: songtitlearray and songpatharray, with the subscripts starting from zero.

You can loop through them, I have quickly output the info. to control arrays of labels but you could easily write the info. out to your database within the loop:

Code:
For counter = 0 To UBound(songtitlearray)
    Label1(counter) = songpatharray(counter)
    Label2(counter) = songtitlearray(counter)
Next


Sorry about the late reply, I hadn't seen this post until now, apologies if you have already found the solution!!

Regards,

Bob

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > How to extract certain data patterns from textbox input?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT