Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-16
8
Medium Priority
?
193 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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
 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…

824 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