|
Yes, you are right.
Declare the variable at the "Form" level and you will be able to manipulate the text of the button.
You could do this with a boolean.
Dim butClicked as boolean = False
Inside your button click event.
If (butClicked) then
set text to aaa
else
set text to bbb
butClicked = Not butClicked
|
|
|
|
|
Hi developers .I have some problem in my project which is on employee timein and timeout.when an employee login in the morning my timein button should accept the timein and add it to the database(ms access).when an employee wants to logout in the evening the timein and timeout form should validate the timein field in the database if timein field contains the login time then form button should active as timeout ,but it is not validating in my project so kindly can anyone help me.so here is my code..:
Dim CN As New OleDbConnection(cnString)
CN.Open()
once if the employee login by its e-id and password it shows the e-name,inthe another textbox.so to select the ename i have coded below.
com2 = New OleDbCommand("SELECT ename from Images WHERE eid ='" & txtemid.Text & "' ", CN)
dr = com2.ExecuteReader
While dr.Read
txtename.Text = dr(0)
'Please below given line is to extarct the only current time except date
txttime.Text = Now.ToShortTimeString
"Now here it is validating for timeout "
com3 = New OleDbCommand("Select * from logtime where eid='" & txtemid.Text & "' and timein<>null and timeout=null and present=null ", CN)
dr1 = com3.ExecuteReader
If dr1.Read Then
Button1.Text = "Time Out"
txttimeout.Text = Now.ToShortTimeString
Exit Sub
Else
End If
|
|
|
|
|
Hi guys,
I need to find text with a specific font color and change its color to another one.
This is more or less what I got:
With ActiveDocument.Content.Find
.ClearFormatting
.Text = ""
.Font.Color = RGB(102,102,153)
With .Replacement
.ClearFormatting
.Text = ""
.Font.Color = RGB(80,176,0)
End With
.Execute Replace:=wdReplaceAll
End With
Problem is: this worked in Word 2007, but in Word 2010, the Font.Color property seems to be dropped. I've tried with Font.ColorIndex and Font.ColorIndexBi , but it doesn't do anything. I can only select a few predefined colors (and clearly it doesn't contain the colors I need )
I prefer to avoid looping through every character if possible. Since we're talking about documents that can contain up to 100k words (and more), it wouldn't be really performant, at least not performant enough to use it on let's say 35 docs in batch .
Anybody an idea about how to bypass that palette restriction?
Thanks you guys
modified 10-Apr-13 3:08am.
|
|
|
|
|
The easiest way of deiling with this, is to open a Word 2010 document, start recording a macro. You select the text and change the front color. Stop the macro and look at the code, it should be there
Edit:
It wont work for shapes though
|
|
|
|
|
I'm going to try that Shapes are not an issue (in this case)
And why on earth didn't I think of that
|
|
|
|
|
Hi,
I recorded it and came up with the following code
Selection.Find.ClearFormatting
Selection.Find.Font.color = RGB(102, 102, 153)
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.color = RGB(0, 176, 80)
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Cheers!
|
|
|
|
|
How can i make mp project int .exe file
|
|
|
|
|
What is an "mp project"?
Use the best guess
|
|
|
|
|
I have installed the Crystal report for vs 2010. I want to generate the crystal report for my project. I have written the following code on button click event.
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
Dim sqlQRY As String = "SELECT * FROM Customers"
Dim cmdExec As SqlCeCommand = New SqlCeCommand(sqlQRY, conn)
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter(sqlQRY, conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "Customers")
Dim Report As frmReports = New frmReports
Dim mReport As rptCustomers = New rptCustomers
mReport.SetDataSource(ds)
Report.CrystalReportViewer1.ReportSource = mReport
Report.ShowDialog()
End Sub
But when i run the program I got the following error. What to do?
"Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified."
|
|
|
|
|
I guess you must search[^] for the solution to this one
|
|
|
|
|
Hi,
I'm relative new in vb.net programming, so I have some questions about printer settings, printer properties.
How could I share a local printer? Also I would like to access another PC and share a printer installed on that computer. How could I do that?
I used the following vbscript code, but I can't convert it to vb.net:
strComputer = "w20hy050"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Name = 'Customer'")
For Each objPrinter in colInstalledPrinters
objPrinter.Shared = TRUE
objPrinter.ShareName = "Customer"
objPrinter.Put_
Next
Thanks for your help.
modified 5-Apr-13 11:32am.
|
|
|
|
|
Robert Kadar wrote: I can't convert it to vb.net:
There's a Proces class that you can use to launch your vb-script.
Robert Kadar wrote: Also I would like to access another PC and share a printer installed on that computer. How could I do that?
You'd probably need local admin-rights on that computer.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
That script uses WMI . WMI can also be used in .Net programs.
|
|
|
|
|
Sir,
I have created this program and it works perfect.
' Created by SharpDevelop.
' User: Zubair Khalid
' Date: 4/5/2013
' Time: 10:56 AM
'
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO
Imports System.Security.AccessControl
Public Partial Class MainForm
Public Sub New()
' The Me.InitializeComponent call is required for Windows Forms designer support.
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
End Sub
Sub Fldrbrws2Click(sender As Object, e As EventArgs)
If True Then
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
fldrpath2.Text = folderBrowserDialog1.SelectedPath
End If
End If
End Sub
Sub Fldrlock2Click(sender As Object, e As EventArgs)
Try
Dim folderPath As String = fldrpath2.Text
Dim adminUserName As String = Environment.UserName
' getting your adminUserName
Dim ds As DirectorySecurity = Directory.GetAccessControl(folderPath)
Dim fsa As New FileSystemAccessRule(adminUserName, FileSystemRights.FullControl, AccessControlType.Deny)
ds.AddAccessRule(fsa)
Directory.SetAccessControl(folderPath, ds)
MessageBox.Show("Locked")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub Fldrunlock2Click(sender As Object, e As EventArgs)
Try
Dim folderPath As String = fldrpath2.Text
Dim adminUserName As String = Environment.UserName
' getting your adminUserName
Dim ds As DirectorySecurity = Directory.GetAccessControl(folderPath)
Dim fsa As New FileSystemAccessRule(adminUserName, FileSystemRights.FullControl, AccessControlType.Deny)
ds.RemoveAccessRule(fsa)
Directory.SetAccessControl(folderPath, ds)
MessageBox.Show("UnLocked")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub MainFormLoad(sender As Object, e As EventArgs)
Dim form As New Form1
form.ShowDialog
End Sub
End Class
But When I embed this code in my another project (converted from C# to VB.NET, All other functions work well) it does not works. Only browsing (fldrbrws2) button and lock (fldrlock2) button work perfectly but Unlock button (fldrunlock2) does not work perfectly. Its shows that it has unlocked but it does not.
here is my another project (in which i want to embed):
Imports System.ComponentModel
Imports System.Data
Imports System.Text
Imports System.Xml
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO
Imports System.Security.AccessControl
Public Partial Class Form1
Inherits Form
Public status As String
'bool flag = true;
Private arr As String()
Private _pathkey As String
Public Sub New()
InitializeComponent()
arr = New String(5) {}
status = ""
arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}"
arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}"
arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}"
arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}"
arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
End Sub
Public Property pathkey() As String
Get
Return _pathkey
End Get
Set
_pathkey = value
End Set
End Property
Private Sub button1_Click(sender As Object, e As EventArgs)
On Error Resume Next
status = arr(0)
'If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Dim d As New DirectoryInfo(fldrpath1.Text)
Dim selectedpath As String = d.Parent.FullName & d.Name
If fldrpath1.Text.LastIndexOf(".{") = -1 Then
If checkBox1.Checked Then
setpassword(fldrpath1.Text)
End If
If Not d.Root.Equals(d.Parent.FullName) Then
d.MoveTo(d.Parent.FullName & "\" & d.Name & status)
Else
d.MoveTo(d.Parent.FullName & d.Name & status)
fldrst1.Text ="Locked (Password Protected)"
End If
fldrpath1.Text = folderBrowserDialog1.SelectedPath
'pictureBox1.Image = Image.FromFile(Application.StartupPath & "\lock.jpg")
fldrst1.Text = "Locked"
Else
status = getstatus(status)
Dim s As Boolean = checkpassword()
If s Then
File.Delete(folderBrowserDialog1.SelectedPath & "\p.xml")
d.MoveTo(folderBrowserDialog1.SelectedPath.Substring(0, folderBrowserDialog1.SelectedPath.LastIndexOf(".")))
fldrpath1.Text = folderBrowserDialog1.SelectedPath.Substring(0, folderBrowserDialog1.SelectedPath.LastIndexOf("."))
'pictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
fldrst1.Text = "Unocked"
End If
End If
'End If
fldrlock1.Enabled = False
fldrpath1.Text = ""
End Sub
Private Function checkpassword() As Boolean
Dim read As XmlTextReader
If pathkey Is Nothing Then
read = New XmlTextReader(folderBrowserDialog1.SelectedPath & "\p.xml")
Else
read = New XmlTextReader(pathkey & "\p.xml")
End If
If read.ReadState = ReadState.[Error] Then
Return True
Else
Try
While read.Read()
If read.NodeType = XmlNodeType.Text Then
Dim c As New checkpassword()
c.pass = read.Value
If c.ShowDialog() = DialogResult.OK Then
read.Close()
Return c.status
End If
End If
End While
Catch
Return True
End Try
End If
read.Close()
Return False
End Function
Private Function setpassword(path As String) As [Boolean]
On Error Resume Next
Dim p As New password()
p.path = path
p.ShowDialog()
Return True
End Function
Private Function getstatus(stat As String) As String
On Error Resume Next
For i As Integer = 0 To 5
If stat.LastIndexOf(arr(i)) <> -1 Then
stat = stat.Substring(stat.LastIndexOf("."))
End If
Next
Return stat
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs)
On Error Resume Next
Dim os As New os
os.ShowDialog
If Me.pathkey IsNot Nothing Then
Dim d As New DirectoryInfo(pathkey)
Dim selectedpath As String = d.Parent.FullName & d.Name
If pathkey.LastIndexOf(".{") = -1 Then
fldrpath1.Text = pathkey
Dim r As DialogResult
r = MessageBox.Show("Do You want to set password ? ", "Question?", MessageBoxButtons.YesNo)
If r = DialogResult.Yes Then
setpassword(pathkey)
End If
status = arr(0)
If Not d.Root.Equals(d.Parent.FullName) Then
d.MoveTo(d.Parent.FullName & "\" & d.Name & status)
Else
d.MoveTo(d.Parent.FullName & d.Name & status)
End If
'pictureBox1.Image = Image.FromFile(Application.StartupPath & "\lock.jpg")
Else
status = getstatus(status)
Dim s As Boolean = checkpassword()
If s Then
File.Delete(pathkey & "\p.xml")
d.MoveTo(pathkey.Substring(0, pathkey.LastIndexOf(".")))
fldrpath1.Text = pathkey.Substring(0, pathkey.LastIndexOf("."))
'pictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
End If
End If
End If
End Sub
Sub Button2Click(sender As Object, e As EventArgs)
On Error Resume Next
status = arr(0)
'If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Dim d As New DirectoryInfo(fldrpath1.Text)
Dim selectedpath As String = d.Parent.FullName & d.Name
status = getstatus(status)
Dim s As Boolean = checkpassword()
If s Then
File.Delete(fldrpath1.Text & "\p.xml")
d.MoveTo(fldrpath1.Text.Substring(0, fldrpath1.Text.LastIndexOf(".")))
fldrpath1.Text = fldrpath1.Text.Substring(0, fldrpath1.Text.LastIndexOf("."))
'pictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
fldrlock1.Enabled = True
fldrpath1.Text = ""
fldrst1.Text ="Unocked"
End If
'End If
End Sub
Sub Button3Click(sender As Object, e As EventArgs)
On Error Resume Next
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Dim d As New DirectoryInfo(folderBrowserDialog1.SelectedPath)
Dim selectedpath As String = d.Parent.FullName & d.Name
fldrpath1.Text = folderBrowserDialog1.SelectedPath
fldrlock1.Enabled = True
End if
End Sub
Sub Fldrbrws2Click(sender As Object, e As EventArgs)
On Error Resume Next
If folderBrowserDialog2.ShowDialog() = DialogResult.OK Then
fldrpath2.Text = folderBrowserDialog2.SelectedPath
End If
End Sub
Sub Fldrlock2Click(sender As Object, e As EventArgs)
Try
Dim folderPath As String = fldrpath2.Text
Dim adminUserName As String = Environment.UserName' getting your adminUserName
Dim ds As DirectorySecurity = Directory.GetAccessControl(folderPath)
Dim fsa As New FileSystemAccessRule(adminUserName, FileSystemRights.FullControl, AccessControlType.Deny)
ds.AddAccessRule(fsa)
Directory.SetAccessControl(folderPath, ds)
fldrst3.Text = "Locked"
fldrpath2.Text = ""
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub Fldrunlock2Click(sender As Object, e As EventArgs)
Try
Dim folderPath As String = fldrpath2.Text
Dim adminUserName As String = Environment.UserName
' getting your adminUserName
Dim ds As DirectorySecurity = Directory.GetAccessControl(folderPath)
Dim fsa As New FileSystemAccessRule(adminUserName, FileSystemRights.FullControl, AccessControlType.Deny)
ds.AddAccessRule(fsa)
Directory.SetAccessControl(folderPath, ds)
fldrst3.Text = "Unlocked"
fldrpath2.Text = ""
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
|
|
|
|
|
I am not going to review your code; I am going to make suggestions.
Have you tried to debug the code to determine where the problem is?
What actions have YOU taken to determine what is happening?
|
|
|
|
|
Zubair Khalid wrote: I have created this program and it works perfect.
Cool.
Zubair Khalid wrote: But When I embed this code in my another project (converted from C# to VB.NET, All other functions work well) it does not works.
C# and VB.NET are both translated to IL. If converting it breaks it, then don't convert it. You can reference the code from any .NET language, as long as you have a compiled assembly.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok now you are just trying to confuse things with compiled assembly.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
One could also reference a project that has not been built. To keep things simple, I decided to not mention the not-yet-compiled-assembly option
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am getting this Error:
Quote: Index was out of range. Must be non-negative and less than the size of the collection.
I have two winforms, and i am trying to pass data between them
Form1 has Gridview which binds to a Store procedure that selects 8 parameters from a "Guardian Table".
form2 has 8 textboxes that I want the data from Form 1 to be displayed
what I want to do is by clicking "LookUp" Button (On FORM2) to get to FORM1 and get the selected row data (when the user selects one row) and display it on form 2
Now here is my code for both forms:
Public Sub getChangesFromForm2(ByVal text1 As String, ByVal text2 As String, ByVal text3 As String, ByVal text4 As String, ByVal text5 As String, ByVal text6 As String, ByVal text7 As String, ByVal text8 As String)
DataGridView1.SelectedRows(0).Cells(0).Value = text1
DataGridView1.SelectedRows(0).Cells(1).Value = text2
DataGridView1.SelectedRows(0).Cells(2).Value = text3
DataGridView1.SelectedRows(0).Cells(3).Value = text4
DataGridView1.SelectedRows(0).Cells(4).Value = text5
DataGridView1.SelectedRows(0).Cells(5).Value = text6
DataGridView1.SelectedRows(0).Cells(6).Value = text7
DataGridView1.SelectedRows(0).Cells(7).Value = text8
End Sub
FORM 2:
Private Sub LookUpBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookUpBtn.Click
GuardianBasicList.getChangesFromForm2(GuardianIDTxt.Text, GuardianPhoneTxt.Text, GuardianFNameTxt.Text, GuardianMNameTxt.Text, GuardianLNameTxt.Text, GuardianEmergContFNameTxt.Text, GuardianEmergContLNameTxt.Text, GuardianEmergContPhoneTxt.Text)
GuardianBasicList.Show()
End Sub
What am I doing wrong? is there another way of achieving the same result??
ANY HELP given is highly appreciated.
Thank you
|
|
|
|
|
VB.Net is not my strong suit, But You should be passing the info as a class in your form2 constructor. Then just assign the data to the text boxes.
Hope this helps
Frazzle the name say's it all
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods
|
|
|
|
|
Hello, i need to search an a code on an excel file then look for a file with that code and then replace name with another column in the excel file..
example:
CODE NAME
123 ABC
456 AB1
789 AB2
012 AB3
so get first code, look it up on a file list. then get name and rename file withe name...
|
|
|
|
|
|
What have you done so far? Where are you stuck?
Do you want to do that with VBA, VB.NET, C#, any???
|
|
|
|
|
VBA for Excel. Data stored in Sheet1, columns: A - CODE, B - NAME. Searches for files in the same folder in which is stored workbook.
Option Explicit
Sub ChangeTheNamesOfFiles()
Dim wsh As Worksheet
Dim sInitialPath As String, sOldName As String, sNewName As String, sExt As String
Dim i As Integer
sInitialPath = ThisWorkbook.Path & "\"
sExt = ".txt"
Set wsh = ThisWorkbook.Worksheets(1)
i = 2
Do While wsh.Range("A" & i)
sOldName = wsh.Range("A" & i)
sOldName = FindFile(sInitialPath, sOldName, sExt)
sNewName = sInitialPath & wsh.Range("B" & i) & sExt
If sOldName <> "" Then
FileCopy sOldName, sNewName
Kill sOldName
End If
Loop
End Sub
Function FindFile(ByVal sDir As String, ByVal sFileName As String, Optional ByVal sFileExt As String = ".txt") As String
Dim retVal As String
If Right(sDir, 1) <> "\" Then sDir = sDir & "\"
retVal = Dir(sDir & sFileName & sFileExt, vbNormal)
FindFile = retVal
End Function
Maciej Los
|
|
|
|
|
Dear all,
I'am trying to build a search program using Excel 2003 Macro, i have trouble when i click this command always shown this message : "Run Time Error '1004': Application-defined or object-defined error".
Need your help to check where the wrong syntax code of my program,
Private Sub cmdCari_Click()
Set wsDtbsCont = Sheets("DataContainer")
Set rgDtbsCont = wsDtbsCont.Range("DataContainer")
Set c = rgDtbsCont.Find(txtContNo.Value, LookIn:=xlValues)
txtCarrier.Value = c.Offset(0, 1).Value
cmbForwarder.Value = c.Offset(0, 2).Value
txtSeal.Value = c.Offset(0, 3).Value
txtStatus.Value = c.Offset(0, 4).Value
txtArrivalTime.Value = c.Offset(0, 5).Value
txtStuffingTime.Value = c.Offset(0, 6).Value
txtSealTime.Value = c.Offset(0, 7).Value
txtFreeTime.Value = c.Offset(0, 8).Value
txtOverNight.Value = c.Offset(0, 9).Value
End Sub
thank you for every things..
Best Regards,
Ahmad Rifai Yusuf
|
|
|
|
|