Solved

Deighton only !!

Posted on 1998-10-02
7
172 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

828 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