Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-16
8
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

722 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