Solved

Deighton only !!

Posted on 1998-10-02
7
171 Views
Last Modified: 2010-04-30
so .. i am waiting, your 200 points too :)
0
Comment
Question by:accorp
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1437788
You are a new user and wait for 200 Points?

What's happening
0
 

Author Comment

by:accorp
ID: 1437789
did you see? - Deighton only !!!
0
 
LVL 18

Accepted Solution

by:
deighton earned 200 total points
ID: 1437790
Heres my code with two example click events.

I'll Email you the code too for your convenience.

Private Sub GetContent(sFile As String, _
            sAuthor As String, _
            sEmail As String, _
            sTitle As String, _
            sWords As String, _
            sDescription As String)
         
'This is a subroutine to extract the contents of
'your settings in a file called sFile
         
         Dim sStr1 As String
         Dim sres1 As String
         Dim sYourTag1 As String
         Dim c As Long, iFileNumber As Integer
         
         sYourTag1 = "content"
         iFileNumber = FreeFile
         Open sFile For Input As iFileNumber
         
         'Get the contents info for a particular
         
          While Not EOF(1)
            Line Input #iFileNumber, sStr1
            If InStr(UCase(sStr1), "AUTHOR") Then
               sAuthor = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "EMAIL") Then
               sEmail = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "TITLE") Then
               sTitle = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "WORDS") Then
               sWords = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "DESCRIPTION") Then
               sDescription = find_text(sStr1, sYourTag1)
            End If
           
          Wend
             
          Close #1
           

End Sub

Private Function find_text(sString, sTag)

    'Searches a sString for setting sTag
    'e.g. <META name="Author" content="Jim Smith">
    ' find_text(sString,"name") returns Author
   

    Dim i As Integer, iPos As Integer, iStart As Integer

    i = InStr(sString, sTag & "=")
   
    If i <> 0 Then
        iStart = i + Len(sTag) + 1
       
        If Mid(sString, iStart, 1) = """" Then
       
            iPos = iStart + 1
            While Mid(sString, iPos, 1) <> """"
           
                find_text = find_text + Mid(sString, iPos, 1)
                iPos = iPos + 1
       
            Wend
   
        End If
       
    End If


End Function

Private Sub replace_text(sProcess As String, sYourTag As String, sReplace As String)

    'Replace contents for setting in a string

    Dim iPos As Integer
    Dim iLen As Integer
   
    Dim sString As String
   
    iPos = InStr(sProcess, sYourTag & "=")
   
    iPos = iPos + Len(sYourTag) + 1
   
    sString = Left(sProcess, iPos)
   
   
    While Mid(sProcess, iPos + 1 + iLen, 1) <> """"
       
        iLen = iLen + 1
       
    Wend
   
    sProcess = sString & sReplace & Mid(sProcess, iPos + 1 + iLen)
   
End Sub

Private Sub Save_Settings(sFile As String, _
            sAuthor As String, _
            sEmail As String, _
            sTitle As String, _
            sWords As String, _
            sDescription As String)
           
    'Update the file with new settings.
    'the new file is created as a temporary file,
    'then copied over the old one.
           
    Dim iFn1 As Integer
    Dim iFn2 As Integer
    Dim sProcess As String
    Dim sYourTag1 As String
    Dim sTempFile As String
   
    sYourTag1 = "content"
    sTempFile = "c:\temp\1234.txt"
   
    iFn1 = FreeFile
           
    Open sFile For Input As #iFn1
   
    iFn2 = FreeFile
   
    Open sTempFile For Output As #iFn2
           
    While Not EOF(iFn1)
   
        Line Input #iFn1, sProcess
       
        If InStr(UCase(sProcess), "AUTHOR") Then
            Call replace_text(sProcess, sYourTag1, sAuthor)
        ElseIf InStr(UCase(sProcess), "EMAIL") Then
            Call replace_text(sProcess, sYourTag1, sEmail)
        ElseIf InStr(UCase(sProcess), "TITLE") Then
            Call replace_text(sProcess, sYourTag1, sTitle)
        ElseIf InStr(UCase(sProcess), "WORDS") Then
            Call replace_text(sProcess, sYourTag1, sWords)
        ElseIf InStr(UCase(sProcess), "DESCRIPTION") Then
            Call replace_text(sProcess, sYourTag1, sDescription)
        End If
       
        Print #iFn2, sProcess
       
    Wend
   
    Close #iFn1, #iFn2
   
    FileCopy sTempFile, sFile
   
         
End Sub

'Example call

Private Sub Command1_Click()

Dim sFile As String
Dim sAuthor As String
Dim sEmail As String
Dim sTitle As String
Dim sWords As String
Dim sDescription As String


sFile = "a:h.htm"

Call GetContent(sFile, sAuthor, sEmail, sTitle, sWords, sDescription)

text1 = sAuthor
text2 = sEmail
text3 = sTitle
text4 = sWords
text5 = sDescription


End Sub


Private Sub Command2_Click()
   
    Dim sFile As String
    Dim sString As String
    Dim sEmail As String
    Dim sTitle As String
    Dim sWords As String
    Dim sDescription As String
   
   
    sFile = "a:h.htm"
    sString = Text6
    sEmail = Text7
    sTitle = Text8
    sWords = Text9
    sDescription = Text10
   
    Call Save_Settings(sFile, sString, sEmail, sTitle, sWords, sDescription)
   
End Sub










0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:accorp
ID: 1437791
there are some problems
i'll get back with you later

0
 
LVL 9

Expert Comment

by:Dalin
ID: 1437792
accorp,

This seems very fishy...

You did not ask a question.  How does deighton know what you need?  

Why deighton only?  its not like you had a previous question and deighton helped you but did not get any points...




0
 
LVL 18

Expert Comment

by:deighton
ID: 1437793
For reference

This is a link from a previously asked question.

http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10085232
0
 
LVL 14

Expert Comment

by:waty
ID: 1437794
deighton, did you see that at the link
   
http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10085232

the user who asked the quection is acorp and the user for this question is accorp?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question