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.WriteLine("Hello");
    Console.ReadLine() 'wait for keypress
  End Sub
End Module
Check answer


Comments

Dara comment

 Dara

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
IO.FileStream("d:/myimage.jpg",IO.FileMode.Open,
IO.FileAccess.Read)
Dim fstout As IO.FileStream=new
IO.FileStream("d:/test.jpg",IO.FileMode.Create,
IO.FileAccess.Write)
Dim data As Integer
data=fstin.readByte
while data<>-1
fstpout.writeByte(data)
data=fstin.readByte
End while
fstin.close()
fstout.close()


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

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")
File.writeAllBytes("myimage.png",imgdata)


2013-09-22
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
project.


2013-09-22
Dara comment

 Dara

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


2013-09-21
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
Else
PictureBox2.Tag = ""
End If


2013-09-21
CAPTCHA image



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.