Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Deighton only !!

so .. i am waiting, your 200 points too :)
0
accorp
Asked:
accorp
  • 2
  • 2
  • 2
  • +1
1 Solution
 
watyCommented:
You are a new user and wait for 200 Points?

What's happening
0
 
accorpAuthor Commented:
did you see? - Deighton only !!!
0
 
deightonCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
accorpAuthor Commented:
there are some problems
i'll get back with you later

0
 
DalinCommented:
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
 
deightonCommented:
For reference

This is a link from a previously asked question.

http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10085232
0
 
watyCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now