vb.net 2012 its works perfectly
but now iam trying to work at vb6
Private Sub showSelectedButton_Click_1(sender As Object, e As EventArgs) Handles btn1.Click
If ComboBox1.SelectedItem = "one" Then
MsgBox("ok")
ElseIf ComboBox1.SelectedItem = "tow" Then
MsgBox("no")
End If
End Sub
how to selecteditem on VB6 ?
use this :
If ComboBox1.List(ComboBox1.ListIndex) = "one" Then
or
If ComboBox1.Text = "one" Then
Please try with this -
Private Sub showSelectedButton_Click()
If ComboBox1.Text= "one" Then
MsgBox("ok")
ElseIf ComboBox1.Text= "tow" Then
MsgBox("no")
End If
End Sub
Related
I'm currently operating Visual Studio 2012. I have a "URL Scanner" form where once a url is entered into a text box, four web browsers opens up and inputs the url into the site and displays.
My problem is this, I get multiple script error pop ups with a error box that states
"Object doesn't support property or method 'getElementsByClassName'".
I tried looking up related resolutions but can't get it to work. I'm quite new to VB and hope someone could correct my mistake.
Class MainWindow
Dim WithEvents ScriptWindow As WebBrowser
Private Sub Enter_Click(sender As Object, e As RoutedEventArgs) Handles Enter1.Click
If TextBox1.Text = "" Then
MessageBox.Show("Please type a target URL in the space provided!")
Else
'Dim file As System.IO.StreamWriter
Dim theDate As Date
theDate = Format(Now(), "short date")
Textboxdate.Text = theDate
' file = My.Computer.FileSystem.OpenTextFileWriter("URLlogs.txt", True)
'file.WriteLine(TextBox1.Text & " | Date of search: " & Textboxdate.Text)
'file.Close()
Dim path As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\URLlogs.txt"
Dim writer As New System.IO.StreamWriter(path, True)
writer.WriteLine(TextBox1.Text & " | Date of search: " & Textboxdate.Text)
writer.Close()
WebBrowser1.Navigate("https://www.talosintelligence.com/reputation_center/lookup?search=" & TextBox1.Text)
WebBrowser2.Navigate("https://www.ssllabs.com/ssltest/analyze.html?d=" & TextBox1.Text)
WebBrowser3.Navigate("https://sitecheck.sucuri.net/results/" & TextBox1.Text)
WebBrowser4.Navigate("https://quttera.com/detailed_report/" & TextBox1.Text)
End If
End Sub
Private Sub Reset_Click(sender As Object, e As RoutedEventArgs) Handles Reset.Click
TextBox1.Text = ""
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As TextChangedEventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub SuppressScriptErrors()
If (WebBrowser1.Document IsNot Nothing) Then
ScriptWindow = WebBrowser1.Document.Window
End If
End Sub
Private Sub SuppressScriptErrors2()
If (WebBrowser2.Document IsNot Nothing) Then
ScriptWindow = WebBrowser2.Document.Window
End If
End Sub
Private Sub SuppressScriptErrors3()
If (WebBrowser3.Document IsNot Nothing) Then
ScriptWindow = WebBrowser3.Document.Window
End If
End Sub
Private Sub SuppressScriptErrors4()
If (WebBrowser4.Document IsNot Nothing) Then
ScriptWindow = WebBrowser4.Document.Window
End If
End Sub
Private Sub Startpage1_Click(sender As Object, e As RoutedEventArgs) Handles Startpage1.Click
Me.Hide()
Dim startwindow As New StartWindow
startwindow.Show()
End Sub
Private Sub SearchHistory1_Click(sender As Object, e As RoutedEventArgs) Handles SearchHistory1.Click
Dim path As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\URLlogs.txt"
If System.IO.File.Exists(path) = True Then
Process.Start(path)
Else
MessageBox.Show("Please generate a search before proceeding")
End If
End Sub
End Class
I have several arrays named : Array1, Array2, Array3, ... and also some comboboxes named: cboArray1, cboArray2, cboArray3, ....
How can i write a GENERAL code to add elements of each array to corresponding combox. I know following code works, but its not GENERAL and ABSTRACT.
For i = 0 To Array1.Length - 1
cboArray1.Items.Add(Array1(i))
Next
For i = 0 To Array2.Length - 1
cboArray2.Items.Add(Array2(i))
Next
...
Working procedure maybe as follows: 1. Find all comboboxes in form (easy) 2. extract name of a combox (easy) 3. find similar-named array from code (difficult) 4. ....
I can use other sets like List, ... if it makes sense.
Here's what you're asking for using Reflection...though I'm not sure how useful this really is:
Public Class Form1
Private Array1 As String() = {"cat", "dog", "fish"}
Private Array2 As String() = {"alpha", "beta", "gamma"}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WireComboBoxes(Me)
End Sub
Private Sub WireComboBoxes(ByVal container As Control)
For Each ctl As Control In container.Controls
If TypeOf ctl Is ComboBox AndAlso ctl.Name.ToUpper.StartsWith("CBO") Then
Dim cb As ComboBox = DirectCast(ctl, ComboBox)
Dim arrName As String = cb.Name.Substring(3)
Dim fi As System.Reflection.FieldInfo = Me.GetType.GetField(arrName, Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.IgnoreCase)
If Not IsNothing(fi) Then
cb.DataSource = fi.GetValue(Me)
End If
ElseIf ctl.HasChildren Then
WireComboBoxes(ctl)
End If
Next
End Sub
End Class
Hi guys i've been working so far with my system and it's almost done, but there is one thing i can't solve yet(not unless if you help me out).
so here's my code:
Private Sub btnEditmain_Click(sender As Object, e As EventArgs) Handles btnEditmain.Click
Try
editdgv()
Form2.Show()
DataGridView2.AllowUserToAddRows = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
here's the private sub editdgv
Private Sub editdgv()
Dim i = DataGridView2.CurrentRow.Index
With DataGridView2
Form2.txtPeriod.Text = IIf(IsDBNull(.Rows(i).Cells("period").Value), " ", .Rows(i).Cells("period").Value)
Form2.txtVouch.Text = IIf(IsDBNull(.Rows(i).Cells("vouch_amt").Value), " ", .Rows(i).Cells("vouch_amt").Value)
Form2.txtIndivAmt.Text = IIf(IsDBNull(.Rows(i).Cells("individual_amt").Value), " ", .Rows(i).Cells("individual_amt").Value)
Form2.txtCheckno.Text = IIf(IsDBNull(.Rows(i).Cells("check_no").Value), " ", .Rows(i).Cells("check_no").Value)
Form2.txtDmailed.Text = IIf(IsDBNull(.Rows(i).Cells("D_MAILED").Value), " ", .Rows(i).Cells("D_MAILED").Value)
Form2.txtDirno.Text = IIf(IsDBNull(.Rows(i).Cells("DIR_NO").Value), " ", .Rows(i).Cells("DIR_NO").Value)
Form2.txtYrlvl.Text = IIf(IsDBNull(.Rows(i).Cells("year_student").Value), " ", .Rows(i).Cells("year_student").Value)
Form2.txtUpdatedBy.Text = IIf(IsDBNull(.Rows(i).Cells("who_updated").Value), " ", .Rows(i).Cells("who_updated").Value)
End With
End Sub
i was able to pass the value of the selected rows in datagridview to another form(textbox)
all things are working fine from there..
Now what i wanna do is to update that selected datagridview which is now in my textbox(s).
through a button click.
now i'm stuck at saving changes that i've done in the textbox, so it will be updated on the database.
pls help me on how to update the selected row in datagridview in textbox via button click.
thanks!
Public Class Form2
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
End Sub
End Class
I have created this code in notepad. So, it might have some issue.
FORM 1
Private Sub btnEditmain_Click(sender As Object, e As EventArgs) Handles btnEditmain.Click
Try
Dim dt As DataTable = TryCast(DataGridView2.DataSource, DataTable)
Dim dr As DataRow = dt.Rows(DataGridView2.CurrentRow.Index)
Dim frm As New Form2
frm.dr = dr
frm.Show()
DataGridView2.AllowUserToAddRows = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
FORM 2
Public dr As DataRow = Nothing
Private Sub Form2_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
With dr
txtPeriod.Text = IIf(IsDBNull(.Item("period")), vbNullString, .Item("period").ToString)
txtVouch.Text = IIf(IsDBNull(.Item("vouch_amt")), vbNullString, .Item("vouch_amt").ToString)
txtIndivAmt.Text = IIf(IsDBNull(.Item("individual_amt")), vbNullString, .Item("individual_amt").ToString)
txtCheckno.Text = IIf(IsDBNull(.Item("check_no")), vbNullString, .Item("check_no").ToString)
txtDmailed.Text = IIf(IsDBNull(.Item("D_MAILED")), vbNullString, .Item("D_MAILED").ToString)
txtDirno.Text = IIf(IsDBNull(.Item("DIR_NO")), vbNullString, .Item("DIR_NO").ToString)
txtYrlvl.Text = IIf(IsDBNull(.Item("year_student")), vbNullString, .Item("year_student").ToString)
txtUpdatedBy.Text = IIf(IsDBNull(.Item("who_updated")), vbNullString, .Item("who_updated").ToString)
End With
End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
With dr
.Item("period") = txtPeriod.Text
.Item("vouch_amt") = txtVouch.Text
.Item("individual_amt") = txtIndivAmt.Text
.Item("check_no") = txtCheckno.Text
.Item("D_MAILED") = txtDmailed.Text
.Item("DIR_NO") = txtDirno.Text
.Item("year_student") = txtYrlvl.Text
.Item("who_updated") = txtUpdatedBy.Text
End With
dr.Table.AcceptChanges
End Sub
Its been nearly a year since I messed with VB, but I am having an issue on my first assignment of the semester which is supposed to be a refresher. What I am supposed to do is make an application that I input a students name, address, GPA, age by textbox, and which year(freshman, sophomore, other) by radio, and classes by checkbox.
Once filled out I need to take that information and have it previewed in a label.text. If it looks right, I need the textbox.text info concatenated into a listbox. No matter what I try or do it either shows String.Array() in the preview or the program crashes at line 57 any help or insight would be appreciated.
Public Class Form1
'CIS259 Spring 2014 Matthew McQuarrie
'Declare Student Data as a String of 9 arrays
Dim StudentData(8) As String
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'Close application
Me.Close()
End Sub
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
'Clear entire form
txtName.Clear()
txtAddress.Clear()
txtGPA.Clear()
txtAge.Clear()
radFreshman.Checked = False
radSophomore.Checked = False
radOther.Checked = False
chkCIS.Checked = False
chkMath.Checked = False
chkScience.Checked = False
chkHistory.Checked = False
lblPreview.Text = ""
End Sub
Public Sub btnPreview_Click(sender As Object, e As EventArgs) Handles btnPreview.Click
StudentData(0) = txtName.Text
StudentData(1) = txtAddress.Text
StudentData(2) = txtGPA.Text
StudentData(3) = txtAge.Text
'Find which radio button is checked to add to StudentData
If radFreshman.Checked = True Then
StudentData(4) = "Freshman"
ElseIf radSophomore.Checked = True Then
StudentData(4) = "Sophomore"
ElseIf radOther.Checked = True Then
StudentData(4) = "Other"
End If
'Find which check boxes are checked to add to StudentData
If chkCIS.Checked = True Then
StudentData(5) = "CIS"
If chkMath.Checked = True Then
StudentData(6) = "Math"
If chkScience.Checked = True Then
StudentData(7) = "Science"
If chkHistory.Checked = True Then
StudentData(8) = "History"
End If
End If
End If
End If
'Show StudentData ino the text of lblPreview
lblPreview.Text = StudentData(0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8)
End Sub
Private Sub btnStudent_Click(sender As Object, e As EventArgs) Handles btnStudent.Click
'Add StudentData elements to Student list
lstStudents.Items.Add(StudentData(0 & 1 & 2 & 3))
End Sub
End Class
maybe this approach I used here can help, but there a few differences..
my source is database.. I concatenate the fields in the database (the source)
and I display only the text, not the id on the listbox displaymember. you could concatenate the id to the textfield from the source and displya the fullstring contactenated.
'create the adapter
Dim adapterU As New OleDb.OleDbDataAdapter("Select id,nombre+' '+apellido as fullname from users", con)
'create a datatable
Dim datatableU As New DataTable
'bring the info from the adapter (database) into the datatable.
adapterU.Fill(datatableU)
'relate the datasource (datable) to the listbox lsUsers
lsUsers.DataSource = datatableU
lsUsers.ValueMember = "id"
lsUsers.DisplayMember = "fullname"
I need help. Need to do password validation and have no idea why it doesn't work. Could someone tell me what my code is missing or what is actually wrong with my way of thinking? I am connecting it to dataset2 where is the table called Users2. Table consists of two columns: 'Username' and 'Password'. Users2BiningSource.Find should be returning value of an index where a current query is. The returned value is always -1, what I guess means that is not found (false). I am using Microsoft Visual Studio 2012 along with SQL server 2008 SP3, all on windows 7. Thank you for your time and help!
Imports Hotel_Booking_System.DataSet2TableAdapters
Public Class Logging
Public Sub check_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Check_Details()
End Sub
Private Sub Quit_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Public Sub Logging_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Users2TableAdapter.Fill(Me.DataSet2.Users2)
'TODO: This line of code loads data into the 'DataSet2.Users2' table. You can move, or remove it, as needed.
End Sub
Public Sub Check_Details()
Me.Users2BindingSource.AddNew()
Dim Usrnm As String = ""
Usrnm = txtUsername.Text
Dim Pswrd As String = ""
Pswrd = txtPassword.Text
Dim Found As Integer
Found = Users2BindingSource.Find("Username", Usrnm)
Dim Found2 As Integer
Found2 = Users2BindingSource.Find("Password", Pswrd)
If Found >= 0 And Found2 >= 0 And Usrnm = "Admin" Then
Me.Hide()
Booking.Show()
ElseIf Found >= 0 And Found2 >= 0 Then
Me.Hide()
Rooms.Show()
Else
MsgBox("Wrong username or password. Please try again", MsgBoxStyle.DefaultButton1, "SOMETHING WENT WRONG")
End If
Label1.Text = Found 'checking the value of found
Label2.Text = Found2 ' checking the value of found2
End Sub
End Class