I have a listbox with items that have hidden values when I click on it. How would I be able to save the items as a text file? So that I would be able to load it using a button.
↧
Help!
↧
VS 2010 VB form refresh
Hi does anyone know the command to refresh a vb form back to the state when you first open it. I've tried using:
form1.show
me.hide
but this doesn't refresh the form.
form1.show
me.hide
but this doesn't refresh the form.
↧
↧
VS 2012 Control scaling issue with split containers
I have a user who changes their screen scaling to 125% in Windows Display settings to make things easier to read. However this is causing an issue in one of my apps when they run it. Any controls that are in Splitcontainer panels seem to lose their anchor. For example, I have several Textboxes that fill most of the width of the panel & are anchored left & right. When the app runs at 125% scaling, the textboxes no longer fill the width of the panel. They do maintain the gap on the left, but there is a large distance between the right end of the textbox & right border of the panel. This is causing some issues with the functioning of the app.
Does anyone know why this is happening or if there is a work-around? Thanks.
I created a test app to demonstrate the problem:
App when run at 100%
![Name: 100Screen.JPG
Views: 31
Size: 44.1 KB]()
Change scaling to 125%
![Name: CtrlPanel.JPG
Views: 27
Size: 67.2 KB]()
App when run at 125%
![Name: 125Screen.JPG
Views: 27
Size: 52.2 KB]()
You can see how the text boxes & button are a large distance from the right border of their respective panels.
Does anyone know why this is happening or if there is a work-around? Thanks.
I created a test app to demonstrate the problem:
App when run at 100%
Change scaling to 125%
App when run at 125%
You can see how the text boxes & button are a large distance from the right border of their respective panels.
↧
VS 2010 [RESOLVED] run code at specific time
i wrote some code that creates a text file and i would like to run it a specific time once a week. i was wondering what is the best way to do this?
should i create a program and then create a scheduled task in windows xp to run the program at a specific time?
here is the code:
should i create a program and then create a scheduled task in windows xp to run the program at a specific time?
here is the code:
Code:
Dim today As Date = Date.Today
Dim dayDiff As Integer = today.DayOfWeek - DayOfWeek.Sunday
Dim sunday As Date = today.AddDays(-dayDiff)
Dim fileExt As String = sunday.Month.ToString("D2") & "." & sunday.Day.ToString("D2") & "." & sunday.ToString("yy")
Dim csvExt As String = sunday.Year & sunday.Month.ToString("D2") & sunday.Day.ToString("D2")
Dim SaveFilePathName As String = "\\Jobs\Invoice.mjb"
Using sw As New System.IO.StreamWriter(SaveFilePathName, False)
Dim row As String = Nothing
row = "[IMPORT-1]"
row = row & vbCrLf & "LIST=""\\Lists\FILE.dbf"""
row = row & vbCrLf & "SETTINGS=""Invoice Import"""
row = row & vbCrLf & "FILENAME=""\\Invoicing\Invoices_" & csvExt & ".csv"""
row = row & vbCrLf & "PARALLEL=N"
row = row & vbCrLf & "[SUBLIST-1]"
row = row & vbCrLf & "LIST=""\\Lists\INVOICES.dbf"""
row = row & vbCrLf & "FILENAME=""\\Lists\INVOICES " & fileExt & ".dbf"""
row = row & vbCrLf & "DESCRIPTION=""INVOICES " & fileExt & """"
row = row & vbCrLf & "OVERWRITE=Y"
row = row & vbCrLf & "HIDERECORDS=N"
row = row & vbCrLf & "AUTOOPENLIST=N"
sw.WriteLine(row)
End Using
↧
VS 2012 Program slows down, general question!
I was bored, so I created a program to calculate dice rolls. Basically, you choose a lucky number and the number of dice you want to throw, and the program throws the dice until every dice has landed on the lucky number. The program counts the throws needed to nail the lucky number. So it's pretty basic, and just a way for me to practice some multi-threading. It's actually the first time I do it.
I decided to put "CheckForIllegalCrossThreadCalls = False" in Form Load, because there should be no other threads accessing the controls at the same time as the calculation is going. I don't know is this is dumb of me, but we'll see.
The problem is basically that if you throw 1 die, the calculation goes pretty fast. 4 dice makes for approximately 500 throws a second on my computer, but the amount of time it takes increases dramatically. 11 dice takes 4 - 5 seconds to complete 500 throws. My general question is basically if this is normal? I know it will take exponentially more throws to get the lucky number on all of the dice, but the whole process just takes a lot longer when the time per throw decreases so dramatically.
Is this because I have chosen a listbox as my preferred "array", or is it just something to expect? I don't have much experience coding, so the probability of mistakes and coding no-no's is probably big. Still, here is the part of my code doing the "throws":
I decided to put "CheckForIllegalCrossThreadCalls = False" in Form Load, because there should be no other threads accessing the controls at the same time as the calculation is going. I don't know is this is dumb of me, but we'll see.
The problem is basically that if you throw 1 die, the calculation goes pretty fast. 4 dice makes for approximately 500 throws a second on my computer, but the amount of time it takes increases dramatically. 11 dice takes 4 - 5 seconds to complete 500 throws. My general question is basically if this is normal? I know it will take exponentially more throws to get the lucky number on all of the dice, but the whole process just takes a lot longer when the time per throw decreases so dramatically.
Is this because I have chosen a listbox as my preferred "array", or is it just something to expect? I don't have much experience coding, so the probability of mistakes and coding no-no's is probably big. Still, here is the part of my code doing the "throws":
Code:
Private Sub ThreadTask()
Do
rolls = rolls + 1
If rolls > oldrolls + 500 Then
Label1.Text = rolls
oldrolls = rolls
End If
Results.Items.Clear()
itemcount = 0
For k As Integer = 1 To ComboBox1.SelectedItem
Results.Items.Add(rndm.Next(1, 7))
Next k
For Each item In Results.Items
If item = ComboBox2.SelectedItem Then
itemcount = itemcount + 1
If itemcount = ComboBox1.SelectedItem Then
success = True
Label1.Text = rolls
End If
Else
Exit For
End If
Next
Loop While success = False And bu3 = False
End Sub
↧
↧
VS 2012 Wonky Sizing/Auto Scaling randomly started happening.
I have a large project. All of which was rolling smoothly until the other day...
I started noticing some of my labels and links (set to auto size) now stretch over the controls that sit directly below them. Now today I noticed that forms are resizing in a wonky way to! See the attached images for what I'm describing. In the images I am implicitly specifying a size on load. In which you can see is not the same at design time. It's almost as though it's adding an additional border width/height... :confused:
So I'm not sure what was accidently switch on, but I need some help. This for sure is one of those hard question to phrase for any sort of answer on google.
Thanks in advanced.
I started noticing some of my labels and links (set to auto size) now stretch over the controls that sit directly below them. Now today I noticed that forms are resizing in a wonky way to! See the attached images for what I'm describing. In the images I am implicitly specifying a size on load. In which you can see is not the same at design time. It's almost as though it's adding an additional border width/height... :confused:
So I'm not sure what was accidently switch on, but I need some help. This for sure is one of those hard question to phrase for any sort of answer on google.
Thanks in advanced.
↧
VS 2008 [RESOLVED] Check for internet connection
I found this code online quite a while ago and I use it to check for an internet connection. Understanding precisely what is going on eludes me. Checking the documentation is where I will head next, but I'm in search of succinct, candid insight from all of you on here I've grown to trust and respect over the last five years.
vb.net Code:
' Integer value if Internet connection is currently configured Public Const InternetConnectionIsConfigured As Integer = &H40S ''' <summary> ''' Found this on the internet, checks for an internet connection ''' </summary> ''' <param name="lpdwFlags">I have no idea</param> ''' <param name="dwReserved">No clue</param> ''' <returns></returns> ''' <remarks></remarks> Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer
↧
Create dinamic controls and locate them with a For .. Next
Hi all,
I want need to create dinamic labels and textbox, accourding to the numbers of days of the month.
For example "January" have 31 days.
I have created Declare a label.
into the form.load I have created arrays for years and months. In case the meses = 1 it means is January, so it should to be a calendar of 31 days.
What I need to do is name the txtdias with a For Next from Day 1 to Day 31 for the month 1, which is January. But I recieved this error: "Object reference not set to an instance of an object."
Also I need to located several labels every 50 positions vertically into the form.
May I need to create "Friend WithEvents txtdias As System.Windows.Forms.Label" 31 times?
Any one have idea how to do this?
I want need to create dinamic labels and textbox, accourding to the numbers of days of the month.
For example "January" have 31 days.
I have created Declare a label.
Code:
'Declare txtdias.labels
Friend WithEvents txtdias As System.Windows.Forms.Label
Code:
Dim años() As String = {"2014", "2015", "2016", "2017", "2018", "2020", "2021", "2022", "2023", "2024"}
Dim meses() As String = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"}
CBmes.Items.AddRange(meses)
CBAño.Items.AddRange(años)
Initext()
txtdate.Text = Date.Today.Year
txtmonth.Text = Date.Today.Month
If txtmonth.Text = 1 Then
CBmes.Text = meses(0)
End if
Also I need to located several labels every 50 positions vertically into the form.
Code:
If txtmonth.Text = 1 Then
For i As Integer = 1 To 31 Step +1
Me.txtdias.Name = "txtdias" & i
For j As Integer = 80 To 600 Step +50
Me.txtdias.Location = New Point(62, j)
Next j
Me.Controls.Add(Me.txtdias)
Next i
End If
Any one have idea how to do this?
↧
Sending a simulated "ENTER" though streamwriter?
Hey guys, I'm currently at a standstill in development of one of my applications. I can't, for the life of me, figure out a way to send a simulated "enter" key press to a console application (separate from the program I'm developing).
Right now, I spawned a process using a new process, and I redirected my input/output streams to streamreader/writer.
Now, is there a way I can send a simulated "enter" press, after writing characters on the streamwriter?
Other ways I've tried include FindWindow, FindWindowEx, sendMessage - etc to send the simulated enter press, but I'm not very good at working with API's, not to mention the process is prefferablly spawned with a .createnowindow = true. \
Any pointers?
Right now, I spawned a process using a new process, and I redirected my input/output streams to streamreader/writer.
Now, is there a way I can send a simulated "enter" press, after writing characters on the streamwriter?
Other ways I've tried include FindWindow, FindWindowEx, sendMessage - etc to send the simulated enter press, but I'm not very good at working with API's, not to mention the process is prefferablly spawned with a .createnowindow = true. \
Any pointers?
↧
↧
VS 2012 MD5 hash one character wrong?
Good Morning all,
I have got a MD5 has function that accepts a string and returns the hash in hex. I am comparing the result with 3 online hashers to ensure the value is correct however something very strange appears to be happening, They come back with the same code accept mine is missing a random 0. Exmaples:
String: test
My hash: 98F6BCD4621D373CADE4E832627B4F6
Online: 098f6bcd4621d373cade4e832627b4f6
String abcdef
My Hash: E8B501798950FC58AAD83C8C14978E
Online: e80b5017098950fc58aad83c8c14978e
String: 123
My Hash: 202CB962AC5975B964B7152D234B70
Online: 202cb962ac59075b964b07152d234b70
As you can see a random 0 is missing from all of mine not always the first one. I am completely baffled by this.
Here is the functions code:
Please does anyone have any ideas as to what is going wrong. As for calling form code:
tboMD5StringEncrypted.Text = Encryptor.MD5Hash(tboMD5StringOrginal.Text)
I have got a MD5 has function that accepts a string and returns the hash in hex. I am comparing the result with 3 online hashers to ensure the value is correct however something very strange appears to be happening, They come back with the same code accept mine is missing a random 0. Exmaples:
String: test
My hash: 98F6BCD4621D373CADE4E832627B4F6
Online: 098f6bcd4621d373cade4e832627b4f6
String abcdef
My Hash: E8B501798950FC58AAD83C8C14978E
Online: e80b5017098950fc58aad83c8c14978e
String: 123
My Hash: 202CB962AC5975B964B7152D234B70
Online: 202cb962ac59075b964b07152d234b70
As you can see a random 0 is missing from all of mine not always the first one. I am completely baffled by this.
Here is the functions code:
Code:
Public Function MD5Hash(ByVal Input As String)
Dim Inputbytes() As Byte = ASCIIEncoding.ASCII.GetBytes(Input)
Dim OutputHash() As Byte = New MD5CryptoServiceProvider().ComputeHash(Inputbytes)
Dim Output As New StringBuilder(Inputbytes.Length)
For Each b As Byte In OutputHash
Output.Append(Conversion.Hex(b))
Next
Return Output.ToString()
End Function
tboMD5StringEncrypted.Text = Encryptor.MD5Hash(tboMD5StringOrginal.Text)
↧
VS 2005 How to Display Images in LED Display Board
Hi Everyone,
Actually, in vb 2005 i writing some pieces of code to send some lines of text to a led display board and it is successful.
I wanna know what are the basic things I need to do to display an image in a led display board.
Regards
mdyusufali786
Actually, in vb 2005 i writing some pieces of code to send some lines of text to a led display board and it is successful.
I wanna know what are the basic things I need to do to display an image in a led display board.
Regards
mdyusufali786
↧
I want the scanned paper be bigger and high quality for pixel
.
.
.
hello everybody
I want quick help please
I have a simple project in vb.net to Scan paper
but I want the Image of the paper be bigger than tha real size with high quality for pixel because I want the text of the paper and it should be good quality for pixel to be the font clear
I use ( Scanner pro control ) and this is my code
.
.
hello everybody
I want quick help please
I have a simple project in vb.net to Scan paper
but I want the Image of the paper be bigger than tha real size with high quality for pixel because I want the text of the paper and it should be good quality for pixel to be the font clear
I use ( Scanner pro control ) and this is my code
HTML Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AxScanner1.SelectImageSourceByIndex(0)
AxScanner1.DuplexEnabled = True
AxScanner1.FeederEnabled = True
AxScanner1.DPI = 96
AxScanner1.PixelType = 444
AxScanner1.SetCaptureArea(0, 0, 3.4, 2.2)
AxScanner1.Scan()
AxScanner1.View = 0
AxScanner1.Focus()
End Sub
End Class
↧
VS 2010 Using Report viewer with PostgreSQL
Hi buddies,
I am trying to connect the report viewer to a postgreSQL data base but I can't :(
I am using a wizzard report to do that but I dont know which parameters I have to use to connect it.
Can someone help me on this?
Thanks in advance.
I am trying to connect the report viewer to a postgreSQL data base but I can't :(
I am using a wizzard report to do that but I dont know which parameters I have to use to connect it.
Can someone help me on this?
Thanks in advance.
↧
↧
[RESOLVED] IsDate not working as I thought
VS 2012
This is passing an edit. It doesn't seem like it should. Can someone see where I am going wrong?
In the actual code it is getting that value from an Excel column entry.
This is passing an edit. It doesn't seem like it should. Can someone see where I am going wrong?
Code:
If IsDate("01/01/2-13") Then
MsgBox("Good date")
End If
↧
VS 2008 microsoft.visualbasic.compatibility.vb6.BaseOCXarray
i have converted my project to VB 6 to Vb 2008..
getting something this type of error...
how to solve this error.. ??
help me
![Name: Untitled.png
Views: 136
Size: 192.0 KB]()
getting something this type of error...
how to solve this error.. ??
help me
↧
VS 2010 Change listbox part of text color for all items only part of them in vb.net
Hi,everybody
I have button find and listbox.
I would like to know how to change the color of text using listbox.
Only part of it I want to change color for the whole selected items homemade in a listbox and not the full row cuz i have urls in listbox.
I do not want to add these homemade items to listbox cuz i just want to change the color for selected or found items in listbox.
Example:
When select item from combobox after selected item from combobox i click on the button find and shoud mark with color only part of text for all items which contains homemade.
If i select another item from combobox it shoud mark with color for other selected item.
I do not know how else to explain to understand more clearly
but i think you should understand that.
Thanks in advance.
I have button find and listbox.
I would like to know how to change the color of text using listbox.
Only part of it I want to change color for the whole selected items homemade in a listbox and not the full row cuz i have urls in listbox.
I do not want to add these homemade items to listbox cuz i just want to change the color for selected or found items in listbox.
Example:
Code:
If ComboBox1.SelectedItem = "homemade" = True Then
ListBox1.ForeColor = Color.Red
End If
If ComboBox1.SelectedItem = "homemade 2" = True Then
ListBox1.ForeColor = Color.Red
End If
If i select another item from combobox it shoud mark with color for other selected item.
I do not know how else to explain to understand more clearly
but i think you should understand that.
Thanks in advance.
↧
VS 2010 Pre load script help?
Does anyone know if there's any way to pre load a script of another language. Say if I made a button and wanted a script to run after you press it. Is that possible? if so how? Or could someone point me in the right direction? Thank you for your help.
↧
↧
Can UserControl import Business Layer?
I'm trying to create a UserControl that will allow me to import the Business Layer Class that is within my solution. However, when I insert the Imports statement at the top of my UC, there is no Business Layer Class in the intellisense dropdown. Is it NOT possible to do this?
Thanks,
Thanks,
↧
Error Msg when CALLing Independent Sub Proceedure - HELP
I am looking to find out why I am getting an error message when I run this application. The message box works correctly, but that's about it. The error message I am getting is:
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string "C2" to type 'Integer' is not valid.
If anyone can point me into the right direction I would greatly appreciate it. This is for an assignment, so please just provide guidance so that I may correct the problem. Below is the sections of code that I am having issues with. Two independent subs and a click_event. The assignment is specific in having 2 separate subs that 1) calculate and 2)display. I have a feeling it may be the way I am trying to pass the variables/parameters but I am not sure.
Private Sub txtPrevReadng_TextChanged(sender As Object, e As EventArgs) Handles txtPrevReadng.TextChanged
'clears labels when text box altered
lblTotCharge.Text = String.Empty
lblGalUsed.Text = String.Empty
End Sub
'Independent Sub to make calculations********
Private Sub GetGalPrice(ByVal decPricePG, ByVal decCurrentRead, ByVal decPrevRead, ByRef decNewGal, ByRef decSubTot)
decNewGal = decCurrentRead - decPrevRead
decSubTot = decNewGal * decPricePG
End Sub
'Independent sub to display results********
Private Sub Display(ByVal decMinMC, ByVal decSubTot, ByVal decNewGal)
If decSubTot > decMinMC Then
lblTotCharge.Text = decSubTot.ToString("C2")
lblGalUsed.Text = decNewGal.ToString("N2")
Else
lblTotCharge.Text = decMinMC.ToString("C2")
lblGalUsed.Text = decNewGal.ToString("N2")
End If
End Sub
'Calc Click Event -- call subs to calculate and display bill*********
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
Const decPricePG As Decimal = 0.00515
Const decMinMC As Decimal = 19.69
Dim decCurrentRead As Decimal
Dim decPrevRead As Decimal
Dim decNewGal As Decimal
Dim decSubTot As Decimal
Decimal.TryParse(txtCrrntReadng.Text, decCurrentRead)
Decimal.TryParse(txtPrevReadng.Text, decPrevRead)
If decCurrentRead < decPrevRead Then
MessageBox.Show("Current reading must be greater or equal to previous reading.", "Invalid Current Reading Entered", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Call GetGalPrice(decPricePG, decCurrentRead, decPrevRead, decNewGal, decSubTot)
End If
Call Display(decMinMC, decSubTot, decNewGal)
End Sub
End Class
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string "C2" to type 'Integer' is not valid.
If anyone can point me into the right direction I would greatly appreciate it. This is for an assignment, so please just provide guidance so that I may correct the problem. Below is the sections of code that I am having issues with. Two independent subs and a click_event. The assignment is specific in having 2 separate subs that 1) calculate and 2)display. I have a feeling it may be the way I am trying to pass the variables/parameters but I am not sure.
Private Sub txtPrevReadng_TextChanged(sender As Object, e As EventArgs) Handles txtPrevReadng.TextChanged
'clears labels when text box altered
lblTotCharge.Text = String.Empty
lblGalUsed.Text = String.Empty
End Sub
'Independent Sub to make calculations********
Private Sub GetGalPrice(ByVal decPricePG, ByVal decCurrentRead, ByVal decPrevRead, ByRef decNewGal, ByRef decSubTot)
decNewGal = decCurrentRead - decPrevRead
decSubTot = decNewGal * decPricePG
End Sub
'Independent sub to display results********
Private Sub Display(ByVal decMinMC, ByVal decSubTot, ByVal decNewGal)
If decSubTot > decMinMC Then
lblTotCharge.Text = decSubTot.ToString("C2")
lblGalUsed.Text = decNewGal.ToString("N2")
Else
lblTotCharge.Text = decMinMC.ToString("C2")
lblGalUsed.Text = decNewGal.ToString("N2")
End If
End Sub
'Calc Click Event -- call subs to calculate and display bill*********
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
Const decPricePG As Decimal = 0.00515
Const decMinMC As Decimal = 19.69
Dim decCurrentRead As Decimal
Dim decPrevRead As Decimal
Dim decNewGal As Decimal
Dim decSubTot As Decimal
Decimal.TryParse(txtCrrntReadng.Text, decCurrentRead)
Decimal.TryParse(txtPrevReadng.Text, decPrevRead)
If decCurrentRead < decPrevRead Then
MessageBox.Show("Current reading must be greater or equal to previous reading.", "Invalid Current Reading Entered", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Call GetGalPrice(decPricePG, decCurrentRead, decPrevRead, decNewGal, decSubTot)
End If
Call Display(decMinMC, decSubTot, decNewGal)
End Sub
End Class
↧
Directory / File System
I am struggling with how to develop a directory / file system, that is not real, but real inside my program. Behaves and looks like same, but in no way works with your real file system.
I have searched with no luck. Can someone point me in the right direction? Ask any questions to clarify.
Thanks
I have searched with no luck. Can someone point me in the right direction? Ask any questions to clarify.
Thanks
↧