Solved

is it possible to change a text on a hosted website using visual basic

Posted on 2004-09-16
8
179 Views
Last Modified: 2013-11-25
is it possible to change aspecific content or text on hosted website, which is created in php,using vb. take an example of google, in which i would like to change a text under the textfield. is it possible
0
Comment
Question by:raj_ms
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12075793


Hi,

Changing the way text shows in your browser is possilbe.
But note that you can not change the the text which is actually in the website server.(can not be changed without hacking and I'm sure you are not into that)

Changing the way text shows in your browser can be done this way:

Step1: you show the webpage in a webbroswer component which is put on your form.

Step2: you read the HTML of the page.

dim s as string

s=Webbrowser.document.innerhtml

Now s contains HTML (PHD) text. you can find the text and edit it.

then

Webbrowser.document.innerhtml =s




0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12075803
any questions : please mention.
0
 

Author Comment

by:raj_ms
ID: 12075853
i am creating a webeditor for my website, instead of changing all the web page, i have planned to edit only some text using vb.
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12076105
I see,

Since you own that website, so you should be able to go through the steps in my previous comment and

then publish it back to the website.

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 32

Expert Comment

by:Erick37
ID: 12076400
I think you want to edit the PHP file?

If this is correct, then the Internet Transfer Control (which comes with VB) can be used to FTP the file(s) to and from your server.
You can edit the source text using a standard TextBox or via code in VB.

If you need more info or some examples of using the Inet Control, just ask.
0
 

Author Comment

by:raj_ms
ID: 12076697
i want to about ITC of vb
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12077685
See this page. Very good code - http://www.thescarms.com/vbasic/inetftp.asp
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 12077805
Here is a simple example of how th use the inet control to download, modify, and upload your files...

Internet Transfer Control reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/inet98/html/vbobjInternetControl.asp

The code:

Option Explicit

'Add the "Microsoft Internet Transfer Control" to your form (Project->Components)
'Add 1 TextBox and 2 Command Buttons
'This example uses FTP to download a file from a server,
'Display its contents in a textbox, and then upload the modified text.
'Set Text1.MultiLine = True
'Set Text1.ScrollBars = Both

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim sFileText As String
Dim sURL As String
Dim sPass As String
Dim sUser As String
Dim sRemoteFile As String
Dim sLocalFile As String

Private Sub Form_Load()
    Command1.Caption = "Download"
    Command2.Caption = "Upload"
    'For our test set the server values here
    sURL = "ftp://ftp.yourserver.com"
    sRemoteFile = "/test.php"
    sLocalFile = "c:\test.php"
    sUser = "yourusername"
    sPass = "yourpassword"
End Sub

Private Sub Command1_Click()
'
'File Download
'
    On Error GoTo FTPGETERROR
    Dim ff As Long
    Dim sTmp As String
    Dim lLen As Long
    'prevent reentrance
    Command1.Enabled = False
    'download our file
    With Inet1
    .Protocol = icFTP
    .RequestTimeout = 60
    .RemotePort = 21
    .AccessType = icDirect
    .URL = sURL
    .UserName = sUser
    .Password = sPass
    End With
   
    'retrieve the file from the server
    Inet1.Execute , "GET " & sRemoteFile & " " & sLocalFile
    Wait
    'now load the file into the textbox
    ff = FreeFile
    Text1.Locked = True 'Prevent user input
    Text1.Text = "" ' Clear out the old text
   
    'Read the file into the textbox
    Open sLocalFile For Input As #ff
    lLen = LOF(ff)        'LOF function returns length of file
    Text1.Text = Input$(lLen, ff)
    Close #ff   ' Close file.
   
    Text1.Locked = False 'Reenable it
    Command1.Enabled = True
    Exit Sub
FTPGETERROR:
    MsgBox "Error: " & Err.Number & " " & Err.Description, vbCritical, Err.Source
    Command1.Enabled = True
    Text1.Locked = False
End Sub

Private Sub Command2_Click()
'
'File Upload
'
    On Error GoTo FTPPUTERROR
    Dim ff As Long
    'prevent reentrance
    Command2.Enabled = False
    'upload our file
    With Inet1
    .Protocol = icFTP
    .RequestTimeout = 60
    .RemotePort = 21
    .AccessType = icDirect
    .URL = sURL
    .UserName = sUser
    .Password = sPass
    End With

    Text1.Locked = True 'Prevent user input
    'Write the text to our local file
    ff = FreeFile
    Open sLocalFile For Output As #ff
    Print #ff, Text1.Text
    Close #ff   ' Close file.
    Text1.Locked = False 'Reenable it
    'Put the file to the server
    Inet1.Execute , "PUT " & sLocalFile & " " & sRemoteFile
    Wait
    Command2.Enabled = True
    Exit Sub

FTPPUTERROR:
    MsgBox "Error: " & Err.Number & " " & Err.Description, vbCritical, Err.Source
    Command2.Enabled = True
    Text1.Locked = False
End Sub

Private Sub Wait()
    Do While (Inet1.StillExecuting = True)
        DoEvents
        Sleep 50
    Loop
End Sub
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now