Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Code to create XML file in vb.net

Answer»

As all of us know xml is platform independent language so we can use xml in ANOTHER platforms very easily. In vb.net we use XmlTextWriter class to CREATE new xml file. And code is given below:-

Imports System.Xml
Public Class Form1
Private Sub Btnxmlcreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnxmlcreate.Click
Dim writer As New XmlTextWriter("xmlfilename.xml", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("Table")
createxmlNode(1, "interviewqsn.com")
createxmlNode(2, "getproductprice.com")
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
END Sub
Private Sub createxmlNode(ByVal pID As String, ByVal pName As String, ByVal pPrice As String, ByVal writer As XmlTextWriter)
writer.WriteStartElement("Product")
writer.WriteStartElement("Product_id")
writer.WriteString(pID)
writer.WriteEndElement()
writer.WriteStartElement("Product_name")
writer.WriteString(pName)
writer.WriteEndElement()
writer.WriteEndElement()
End Sub
End Class

2.

How to get number of hits to website in vb.net

Answer»

Below code is done in Global.asax and done by application and session variable:-
Sub Application_Start(BYVAL sender As Object, ByVal e As EventArgs)
'below varible count Hits done by VISITORS
Application("count") = 0
END Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
'here we will lock the Application for concurrency ISSUES
Application.Lock()
'below code is for increment the COUNTER
Application("count") = Application("count") + 1
'Now we unlock the Application
Application.UnLock()
End Sub

3.

Killing Process of excel and powerpoint using vb.net

Answer»

Below code is USED to KILL process of excel and powerpoint with USING vb.net:-

Private SUB Button1_Click(ByVal sender As System.Object, ByVal E As System.EventArgs) Handles Button1.Click
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
For Each p As Process In pProcess
p.Kill()
Next
Dim pProcess2() As Process = System.Diagnostics.Process.GetProcessesByName("POWERPNT")
For Each p As Process In pProcess2
p.Kill()
Next
End Sub

4.

How to bind GridView with xml file

Answer»

Below code will BIND xml FILE with the GridView:-
DIM D_Set As New System.Data.DataSet
D_Set.ReadXml(Server.MapPath("XMLFileName.xml"))
GridView1.DataSource = D_Set.Tables(0)
GridView1.DataBind()

5.

Code to use brush in vb.net

Answer»

Below CODE is used to do drawing first

Imports System.Drawing
Imports System.Drawing.Imaging
Partial Class Usebrush
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal SENDER As OBJECT, ByVal e As System.EventArgs) Handles Me.Load
DIM b As New Bitmap(150, 150, PixelFormat.Format32bppArgb)
Dim G As Graphics = Graphics.FromImage(b)
Dim br As Brush = Brushes.Yellow
g.FillEllipse(br, 5, 5, 140, 140)
Response.ContentType = "image/gif"
b.Save(Response.OutputStream, ImageFormat.Gif)
b.Dispose()
End Sub
End Class

6.

Code to Use enter key as tab key in vb.net on textbox

Answer»

Public Class FORMNAME
PRIVATE Sub txtboxid_KeyPress(BYVAL sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) HANDLES txtboxid.KeyPress
If e.KeyChar = Chr(13) Then
SendKeys.Send("{TAB}")
e.Handled = True
End If
End Sub
End Class

7.

How to check internet explorer is running

Answer»

Below code helps to to get WHETHER Internet Explorer is RUNNING or not running:-
DIM myProcesses As PROCESS() = Process.GetProcessesByName("iexplore")
Dim myProcess As Process
For Each myProcess In myProcesses
If myProcess.ProcessName.ToString IsNot Nothing Then
MsgBox(myProcess.ProcessName.ToString)
ElseIf myProcess.ProcessName.ToString Is "" Then
MsgBox("closed")
End If
Next myProcess

8.

How to check wheather character is string or numeric

Answer»

Bellwo code will helps you to GET wheather CHARACTER is STRING or numeric

Sub MAIN()
DIM sValue As String = "1Abc"
Dim sValueAsArray = sValue.ToCharArray()
If IsNumeric(sValueAsArray(0)) Then
Console.WriteLine("First character is numeric")
Else
Console.WriteLine("First character is not numeric")
End If
Console.ReadLine()
End Sub

9.

number of time a charcter occur

Answer»

Dim lit As Char
Dim Count As Integer = 0
Dim Count1 As Integer = 0
Dim Duplicate As Char = "A"
Dim STR As String = "1 3 2 6 2 4 2 6 7 2 5 2"
Dim i As Integer
For i = 0 To str.Length- 1 Step i + 1
lit = str(i)
Dim j As Integer
For j = 1 To str.Length- 1 Step j + 1
If lit = str(j) Then
Count = Count + 1
End If
NEXT
If Count > Count1 Then
Count1 = Count
Duplicate = str(i)
End If
Next
Response.Write(Duplicate.ToString())