VB.NET Questions/Answers-VB.NET basic syntax(PartI)

VB.NET basic syntax(PartI)

1. In VB.NET, the comment is a quote character(').
a. True    b. False Check answer 2. In VB.NET, the Console.ReadLine input statement is used to receive data from keyboard in a console program.
a. True   b. False Check answer 3. The Console.WriteLine output statement is used to print text on the screen with a new line.
a. True   b. False Check answer 4. Each VB.NET console program may have many Main sub- procedures with the same signatures(name, number of arguments, types of arguments, etc.)
a. True    b. False Check answer 5. To declare an integer variable in VB.NET language, which one of the following statements is true?
a. Dim x As Single      b. Dim x As Integer    c. x As Integer Check answer 6. Which of the following is not a numerical type?
a.Integer    b.Char    c.Single   d.Date   e.Double Check answer 7. In VB.NET language, Which one is not the integer value?
a.12    b.'23'    c.10    d.100 Check answer 8. What is the type of each of the following constants?
a.10    b.'2'    c.10.7    d."12" Check answer 9. What is the type of each of the following constant?
a."Dara"    b.'2.9'    c."10.7"    d.13.9    e.'\a' Check answer 10. Find any errors in the following VB.NET program:
Module Module1
  Sub Main() ' This is the main procedure
    Console.ReadLine() 'wait for keypress
  End Sub
End Module
Check answer


Dara comment


One solution to your problem is to use FileStream class. You will read content of the selected image file and write it to your images folder.

Dim fstin As IO.FileStream=new
Dim fstout As IO.FileStream=new
Dim data As Integer
while data<>-1
End while

You might like to read this page to get the idea about FileStream class www.worldbestlearningcenter.com/index_files/

For another solution, you can use readAllBytes and writeAllBytes methods of the File class to read the content of the image file in to a byte array and then write the byte array to the output file in your images folder.
Dim imgData As Byte()=File.ReadAllBytes("myimage.png")

Leng Vanny comment

 Leng Vanny

In vb.net with access database how to save Image to not from specific folder?
when i click OpenFileDialog select image,click Ok image have to stored to a folder ("images")in vb.net

Dara comment


This code is working.
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String
path = Application.StartupPath & "\images\"
OpenFileDialog1.InitialDirectory = path
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)

End If
End Sub
End Class

Leng Vanny comment

 Leng Vanny

In vb.net with access database how to store Image to specific folder?why this code go wrong?
If OpenFileDialog1.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
PictureBox2.Image = Image.FromFile(OpenFileDialog1.FileName)
PictureBox2.Tag = OpenFileDialog1.FileName
Dim s As String = Application.ExecutablePath & "\images\"
OpenFileDialog1.InitialDirectory = s
Exit Sub
PictureBox2.Tag = ""
End If


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.