So, I've been working on my program for 3 hours now (I'm new to VB),
so I've made the program to change the desktop wallpaper when a button is clicked, and it works fine, I want that as soon as you run the program as an administrator, that it changes the OEMBackground value is changed from 0 to 1,
but it won't work, why?
Imports System.Environment
Imports Microsoft.Win32
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
Public Class Form_Main
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
My.Computer.Audio.Play(My.Resources.Theme, AudioPlayMode.BackgroundLoop)
Dim ChangeValue As Integer
ChangeValue = 1
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", ChangeValue)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Filepath As String
Filepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Microsoft\Windows\Themes\TranscodedWallpaper.jpg"
My.Resources.Monika.Save("TranscodedWallpaper.jpg", Imaging.ImageFormat.Jpeg)
If My.Computer.FileSystem.FileExists(Filepath) Then
My.Computer.FileSystem.DeleteFile(Filepath)
End If
My.Computer.FileSystem.MoveFile("TranscodedWallpaper.jpg", Filepath)
End Sub
End Class
Related
I am using VB.Net 2013 with SQL Server
What is the problem with my code? Is there something missing?
When I try to select the location, it show me in the Form the name, location and the image.
Everything looks good, the only problem is that the image in report viewer doesn't change.
Imports System.IO
Imports Microsoft.Reporting.WinForms
Public Class Form1
Private Sub Table_locationBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles Table_locationBindingNavigatorSaveItem.Click
Me.Validate()
Me.Table_locationBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.KankonDataSet)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'KankonDataSet.Table_location' table. You can move, or remove it, as needed.
Me.Table_locationTableAdapter.Fill(Me.KankonDataSet.Table_location)
If NamelocationComboBox.Text = Nothing Then
NamelocationComboBox.Text = "No thing"
End If
If IdlocationTextBox.Text = Nothing Then
IdlocationTextBox.Text = "No thing"
End If
Dim Param1 As New ReportParameter("ReportParameterlocation", NamelocationComboBox.Text)
ReportViewer1.LocalReport.SetParameters(Param1)
Dim Param2 As New ReportParameter("ReportParameterwhere", IdlocationTextBox.Text)
ReportViewer1.LocalReport.SetParameters(Param2)
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub ReportViewer1_Load(sender As Object, e As EventArgs) Handles ReportViewer1.Load
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub NamelocationComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles NamelocationComboBox.SelectedIndexChanged
Dim Param1 As New ReportParameter("ReportParameterlocation", NamelocationComboBox.Text)
ReportViewer1.LocalReport.SetParameters(Param1)
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub IdlocationTextBox_TextChanged(sender As Object, e As EventArgs) Handles IdlocationTextBox.TextChanged
Dim Param2 As New ReportParameter("ReportParameterwhere", IdlocationTextBox.Text)
ReportViewer1.LocalReport.SetParameters(Param2)
Me.ReportViewer1.RefreshReport()
End Sub
End Class
Image in Attachments!
i have start a new application to encrypt strings and save them on my settings the code its work fine but wen it save it save multiple times the same.
How can i do for save all the content from a listbox to my settings with out to repeat.
This is my code
Imports System.Text
Imports System.Security.Cryptography
Imports System
Imports System.Collections
Imports System.Collections.Specialized
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'My.Settings.md5_hashes.Clear()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim md5 As MD5 = System.Security.Cryptography.MD5.Create()
Dim inputBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
Dim hash As Byte() = md5.ComputeHash(inputBytes)
Dim sb As New StringBuilder()
For i As Integer = 0 To hash.Length - 1
sb.Append(hash(i).ToString("x2"))
Next
TextBox2.Text = sb.ToString
ListBox1.Items.Add(TextBox1.Text + "<--->" + TextBox2.Text)
My.Settings.md5_hashes.Add(TextBox1.Text + "<--->" + TextBox2.Text)
My.Settings.Save()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
For Each item In My.Settings.md5_hashes
ListBox1.Items.Add(item)
Next
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
For Each item In My.Settings.md5_hashes
ListBox1.Items.Add(item)
Next
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Well i just solved my self the problem its because wen i start the timer its is there the code to retrieved all the content from my settings to the listbox.
I just removed and solved.
Sorry for bad english
I want the available ssid list in listbox
I am use api and its work but It stopped working after a while.And not see current wifi list.
My code:
Imports deneme2.NativeWifi
Imports System.Text
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
Private Sub scan()
On Error Resume Next
Dim client As New WlanClient
ListView1.Items.Clear()
For Each wlanIface As WlanClient.WlanInterface In client.Interfaces
Dim networks() As Wlan.WlanAvailableNetwork = wlanIface.GetAvailableNetworkList(0)
For Each network As Wlan.WlanAvailableNetwork In networks
Dim ssid As Wlan.Dot11Ssid = network.dot11Ssid
Dim networkName As String = Encoding.ASCII.GetString(ssid.SSID, 0, CType(ssid.SSIDLength, Integer))
Dim item As ListViewItem = New ListViewItem(networkName)
item.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString())
item.SubItems.Add(network.wlanSignalQuality.ToString + "%")
ListView1.Items.Add(item)
Next
Next
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
scan()
End Sub
End Class
Could someone please guide me as to how I would get this actually working? Currently it gives me errors about WithEvents - although simplified it shows the form - but I have no clue what that actually means. It's an toolbox I'm making just to allow the user to better interact with some of my other code.
All I need is the form visuals/guts to be custom, but then the code to be done within my application (which doesn't have visual editing capabilities).
Is this a case where I need to use interfacing/partial classes/inheritance, or can this easily be accomplished with just some minor tweaking to what I have?
(Form created in visual studio form designer and then changed to a class library. Application code written in Autodesk Inventor "rule" environment)
Thanks!
Application code:
AddReference "C:\Users\Documents\Visual Studio 2013\Projects\WindowsApplication1\WindowsApplication1\bin\Release\SectionSymToolBox.dll"
Imports System.Windows.Forms
Public Class SectionSymRule
'Public dlg As New System.Windows.Forms.For
Public Shared ToolBox As New SectionSymToolBox.SectionSymToolBox
Dim WithEvents EClass As New EventClass
Sub Main()
ToolBox.Show()
End Sub
End Class
Form code:
Public Class SectionSymToolBox
Private Sub Main()
End Sub
Public Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'Swap Symbols
End Sub
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Flip Symbol
End Sub
Public Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Flip Text
End Sub
Public Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
'<
End Sub
Public Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
'>
End Sub
End Class
Is this what you are looking for?
AddHandler ToolBox.Button1.Click, AddressOf HandlerMethodHere
Where HandlerMethod is a method that has the same signature as Button1.Click so for example:
Private Sub HandleButton1Click(sender As Object, e As EventArgs)
'Code here
End Sub
Obviously, replace Button1 with the name of the button.
I am not sure what I am doing wrong.
I viewed the Developer help page for this function but it doesn't have any examples
GetTempPath Help
Rght now I just want to print the temp directory to a msgbox to make sure I am doing it right. Then I will use it to write to a file
I am new to VB.net and am more familiar with C
Here is my code:
Imports System
Imports System.IO
Imports System.Collections
Public Class Form1
Public Shared Function GetTempPath() As String
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
...
...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim tempFolder As String
tempFolder = GetTempPath()
MsgBox(tempFolder)
End Sub
The ellipses just mean there is code there that is unnecessary for the question
You need to remove your Function declaration for GetTempPath. This is causing you to use your function, not the System.IO.Path version. Since Path.GetTempPath is a Shared Function, you call it via Path.GetTempPath().
Your code should look like:
Imports System
Imports System.IO
Imports System.Collections
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
...
...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim tempFolder As String
tempFolder = Path.GetTempPath()
MsgBox(tempFolder)
End Sub