Archive

Posts Tagged ‘Visual Basic’

Visual Basic comes to Linux.

January 18th, 2010 Jimmy No comments

Visual Basic for Linux is here, sort of. In my search for the perfect RAD environment for Linux I came across a project called Gambas. Gambas is a Visual Basic like development environment for Linux which is very much like Microsoft’s drag and drop Visual Basic but it is not a clone. For an Open Source project Gambas makes for a really nice Rapid Application Development (RAD). Adding one line of code I was able to create a basic “hello world” application.

I wouldn’t call the software as complete as Microsoft’s Visual Studio and .NET SDK but it just is easy to use. Gambas is in the Ubuntu software repository so installation is cake.

Check it out here.
http://gambas.sourceforge.net

Uploading files to a web server using Visual Basic.

December 10th, 2009 Jimmy No comments

Do you need to upload a file to your php web server from a .NET application? I did, and I found that it was actually pretty easy. Basically the upload.php file works the same way as a basic HTML website form. You simply do an HTML form post from within your .NET application.

The source code for the VB.NET application:

Dim WC As New System.Net.WebClient

Dim uriString As String = “http://www.yourwebserver.com/upload.php”

Dim fileName As String = “c:\somefile.txt”

Dim responseArray As Byte() = WC.UploadFile(uriString, “POST”, fileName)

MsgBox(System.Text.Encoding.ASCII.GetString(responseArray))

The source code for the PHP upload.php script:

<?php

$uploaddir = "/home/webspace/htdocs/uploads/";

$uploadfile = $uploaddir . basename($_FILES['file']['name']);

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)){

echo "File Uploaded!";

}else{

echo "Problem uploading file.";

}

?> 

Call the .NET code above to upload a file. Make sure you have a writable directory on your php web server. The application should throw a message box up with the results of upload.php. ( Basically whatever upload.php echo’s back. )

Categories: Programming Tags: , , ,