Quantcast
Channel: VBForums
Viewing all 42269 articles
Browse latest View live

New Firefox: BMC MULTI-CLOUD PopUp Driving Me Nuts!

$
0
0
With all my previous Firefox versions that MBC popup nailed me only once and that was when I navigated to the "Visual Basic 6 and Earlier" page. Now the MBC add pops up on every post I click. I have block popups checked but it's not doing squat. This thing is really irritating!

Thanks
Chris

MODS: Please move this. I posted this in the wrong section. Sorry!

[RESOLVED] DateTimePicker - custom DataBinding to return DBNull.Value

$
0
0
Hi,

I've created a custom DateTimePicker which shows empty If Databinded to DBNull.Value, with a trick of setting CustomFormat. Only problem I'm facing is to return DBNull.Value from DateTimePicker when I save changes to DB. Here is my code:

Code:

  public object MyValue
        { 
            //Binding with DBNull
            get
            {
                if (this.Format == DateTimePickerFormat.Custom)
                {
                    return DBNull.Value;
                } 
                else
                {
                    return this.Value;
                }                 
             
            }
            set
            {
                if (value == DBNull.Value)
                {
                    this.Format = DateTimePickerFormat.Custom;
                    this.CustomFormat = " ";
                    //DateTime? dt =DBNull.Value; //error here
                    //Value = (DateTime)dt;
                }
                else
                {
                    this.Format = DateTimePickerFormat.Short;
                    this.Value = (DateTime)value;
                }
            }
        }

I bind to DateTimePicker simply as this: DTP.DataBindings.Add("MyValue", dt, "SOME_COLUMN");

Error I'm facing is "Nullable object must have a value?".

Can somebody help me If there is any solution to this ? Currently I just manually set DB.NULL in place where stored procedure is executed, and I want to get rid of these lines.

VB6 - Very simple CoreAudio Demo (vbRichClient5)

[RESOLVED] Immovable PictureBox and Text Box in VB6

$
0
0
Hi folks. I thought I would dip my toes in the water here, rather than my usual haunts, and hope that someone may be able to help.

I suspect I am missing something obvious. I have an application which I wrote in VB6 a good few years ago and I need to tweak it a little bit.

The main outputs of the program are displayed in either a TextBox or a PictureBox, the two of which are almost totally overlapping, with just one being visible at a time, as required. I need to move these 'a little bit to the right' in order to make room for some new controls.

However, whilst I can happily move them to wherever I want (and/or re-size them) in Design View, when I run the program they still pop up in the same place as before, as if I hadn't changed anything. I can see nothing about the properties of these controls which explains this behaviour, and nor does any of my code alter any of their properties other than "Visible". There are plenty of other controls on the form, and I can move any of them as one would expect, and those changes ARE reflected when I run the program.

As I said, I presume that I am missing something fairly obvious which is causing this behaviour, but I don't think any more scratching of my head is going to reveal it. I therefore wonder if someone suggest what I should be looking at/for.

Thanks in advance.

Kind Regards, John

Need help passing values from one class to another

$
0
0
I have a class called data tier class where i am trying to pass the calculations from my daysoverdueprocal() method to the text box in my reservation form. The method daysoverdueprocal() is suppose to calculate the difference between the dates in my reservation form from my data tier class then place the answer into the text box in my reservation form. I can easily do all of this work in the reservation form and it will work but when i try to do this calculation from the data tier class i cant get the information to pass to the text box in my reservation form.

here is the code below for my data tier class
vb.net Code:
  1. Public Class DataTier
  2.     Dim fineprice As Long
  3.     Private Const mindays As Long = 0
  4.     Sub New(ByVal daysoverduesub As Long, ByVal finesub As Decimal)
  5.         finepro = finesub
  6.         daysoverduepro = daysoverduesub
  7.  
  8.     End Sub
  9.     Private finepri As Decimal = 2.5
  10.     Public Property finepro As Decimal
  11.         Get
  12.             Return finepri
  13.         End Get
  14.         Set(value As Decimal)
  15.             finepri = value
  16.         End Set
  17.     End Property
  18.  
  19.     Private daysoverduepri As Long
  20.     Public Property daysoverduepro As Long
  21.         Get
  22.             Return daysoverduepri
  23.         End Get
  24.         Set(value As Long)
  25.             If value > 0 Then
  26.                 daysoverduepri = value
  27.             End If
  28.  
  29.         End Set
  30.     End Property
  31.  
  32.     Public Sub daysoverduecal()
  33.         If daysoverduepro < 0 Then
  34.             finepro = 0
  35.         End If
  36.         Dim restbl As Reservation_Table = New Reservation_Table
  37.         daysoverduepro = DateDiff(DateInterval.Day, restbl.Due_dateDateTimePicker.Value.Date, restbl.Return_dateDateTimePicker.Value.Date)
  38.         fineprice = daysoverduepro * finepro
  39.     End Sub
  40.     Public ReadOnly Property daysoverdueprocal As Long
  41.         Get
  42.             Return daysoverduepro
  43.         End Get
  44.     End Property
  45.     Public ReadOnly Property finepreicepro As Long
  46.         Get
  47.             Return fineprice
  48.         End Get
  49.     End Property
  50. End Class

This part of the code is suppose to do the calculations to find the difference between the dates from the data tier

Private daysoverduepri As Long
Public Property daysoverduepro As Long
Get
Return daysoverduepri
End Get
Set(value As Long)
If value > 0 Then
daysoverduepri = value
End If

End Set
End Property

Public Sub daysoverduecal()
If daysoverduepro < 0 Then
finepro = 0
End If
Dim restbl As Reservation_Table = New Reservation_Table
daysoverduepro = DateDiff(DateInterval.Day, restbl.Due_dateDateTimePicker.Value.Date, restbl.Return_dateDateTimePicker.Value.Date)
fineprice = daysoverduepro * finepro
End Sub

Public ReadOnly Property daysoverdueprocal As Long
Get
Return daysoverduepro
End Get
End Property

Here is the information from my reservation Form class

vb.net Code:
  1. Public Class Reservation_Table
  2.     Dim daysoverdue As Long
  3.     Dim fine As Decimal = 2.5
  4.  
  5.     Private Shared instance As Reservation_Table
  6.     Public Shared ReadOnly Property ReservationTableInstance() As Reservation_Table
  7.         Get
  8.             If instance Is Nothing Then
  9.                 instance = New Reservation_Table
  10.             End If
  11.             Return instance
  12.         End Get
  13.     End Property
  14.     Private Sub ReservationTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ReservationTableBindingNavigatorSaveItem.Click
  15.         Try
  16.  
  17.             Dim datatiercal As DataTier = New DataTier(daysoverdue, fine)
  18.  
  19.             DayOverduetextbox.Text = datatiercal.daysoverdueprocal
  20.  
  21.             Me.Validate()
  22.             Me.ReservationTableBindingSource.EndEdit()
  23.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  24.  
  25.         Catch ex As Exception
  26.             MessageBox.Show(ex.Message)
  27.         End Try
  28.     End Sub
  29.  
  30.     Private Sub Reservation_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  31.         Try
  32.             'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.ReservationTable' table. You can move, or remove it, as needed.
  33.             Me.BookTableTableAdapter1.Fill(Me.Librarymanagementdatabase2DataSet.BookTable)
  34.             Me.ReservationTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.ReservationTable)
  35.         Catch ex As Exception
  36.             MessageBox.Show(ex.Message)
  37.         End Try
  38.     End Sub
  39.  
  40.     Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
  41.         Try
  42.             ReservationTableBindingSource.AddNew()
  43.             CostTextBox.Text = fine * daysoverdue
  44.             CostTextBox.Text = FormatCurrency(CostTextBox.Text)
  45.         Catch ex As Exception
  46.             MessageBox.Show(ex.Message)
  47.         End Try
  48.  
  49.     End Sub
  50.  
  51.     Private Sub SaveButton_Click_1(sender As Object, e As EventArgs) Handles SaveButton.Click
  52.         Try
  53.             Me.Validate()
  54.             'daysoverdue = DateDiff(DateInterval.Day, Due_dateDateTimePicker.Value.Date, Return_dateDateTimePicker.Value.Date)
  55.             'DayOverduetextbox.Text = daysoverdue
  56.             FormatCurrency(CostTextBox.Text)
  57.             CostTextBox.Text = fine * daysoverdue
  58.             ReservationTableDataGridView.Columns(7).DefaultCellStyle.Format = "c"
  59.             Me.ReservationTableBindingSource.EndEdit()
  60.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  61.         Catch ex As Exception
  62.             MessageBox.Show(ex.Message)
  63.         End Try
  64.     End Sub
  65.  
  66.     Private Sub Reservation_Table_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
  67.         instance = Nothing
  68.     End Sub
  69.     Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click
  70.         Try
  71.             ReservationTableBindingSource.RemoveCurrent()
  72.         Catch ex As Exception
  73.             MessageBox.Show(ex.Message)
  74.         End Try
  75.     End Sub
  76.  
  77.     Private Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click
  78.         Try
  79.             Me.Validate()
  80.             'daysoverdue = DateDiff(DateInterval.Day, Due_dateDateTimePicker.Value.Date, Return_dateDateTimePicker.Value.Date)
  81.             'DayOverduetextbox.Text = daysoverdue
  82.             FormatCurrency(CostTextBox.Text)
  83.             CostTextBox.Text = fine * daysoverdue
  84.             ReservationTableDataGridView.Columns(7).DefaultCellStyle.Format = "c"
  85.             Me.ReservationTableBindingSource.EndEdit()
  86.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  87.         Catch ex As Exception
  88.             MessageBox.Show(ex.Message)
  89.         End Try
  90.     End Sub
  91.  
  92.     Private Sub RenewButton_Click(sender As Object, e As EventArgs) Handles RenewButton.Click
  93.         Due_dateDateTimePicker.Value = Due_dateDateTimePicker.Value.Date.AddDays(7)
  94.         Return_dateDateTimePicker.Value = Due_dateDateTimePicker.Value.Date
  95.     End Sub
  96.  
  97.     Private Sub SearchToolStripButton_Click(sender As Object, e As EventArgs) Handles SearchToolStripButton.Click
  98.         Try
  99.             Me.ReservationTableTableAdapter.Search(Me.Librarymanagementdatabase2DataSet.ReservationTable, ReserverNameToolStripTextBox.Text)
  100.         Catch ex As System.Exception
  101.             System.Windows.Forms.MessageBox.Show(ex.Message)
  102.         End Try
  103.  
  104.     End Sub
  105. End Class

Here is the part of the code i am trying to get the data tier to pass the calculations for the difference between the dates into the text box

Private Sub ReservationTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ReservationTableBindingNavigatorSaveItem.Click
Try

Dim datatiercal As DataTier = New DataTier(daysoverdue, fine)

DayOverduetextbox.Text = datatiercal.daysoverdueprocal

Me.Validate()
Me.ReservationTableBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

arabic in vb 6 and crystal reports 8

$
0
0
hello experts
may be this question is very old, i have an application developed in VB 6 and reports are in Crystal Reports 8.0
I want to add Arabic option in the application,
At data entry text box accepting Arabic characters and they are also saved in database (SQL Server 2008), when i am trying to retrieve record back in vb form or print any reports its show ?????????? instead of arabic characters.
Please if anyone can guide me in right direction,
regads



Imran

VS 2015 Licensing/copy protection DIY

$
0
0
I would like to apply some sort of copy protection functionality to a winforms app of mine. Reading up on discussions on the matter, I find the general advice to be not to write it yourself because commercial software is the only solution that will provide reasonable protection. Secondly, any suggestion for a home crafted solution generally involves some form of mathematical key generation.

This is my thinking: Make an app that generates license keys and puts them in a database. Keys are completely random, GUIDs or the like, no logic involved. Keys are given to paying customers. On the first run of my software, users are prompted to enter the key, if it exists in the database and is unused; the app runs and generates a value that is stored locally (say, a secret number and some hardware ID mixed in some manner that can be calculated backwards in subsequent runs). On the next run the app will make the calculation and run without need to check the database. Making a second install on a different computer would fail.

My question, basically, is: what are the weaknesses of this method? Why can’t I find any suggestions pointing in this direction? I´m not looking to be bullet proof, my potential customers are hardly hackers, I just don’t want them to make lots of copies just because they discover they can.

Should I go buy something?

Need help passing values from one class to another

$
0
0
I have a class called data tier class where i am trying to pass the calculations from my daysoverdueprocal() method to the text box in my reservation form. The method daysoverdueprocal() is suppose to calculate the difference between the dates in my reservation form from my data tier class then place the answer into the text box in my reservation form. I can easily do all of this work in the reservation form and it will work but when i try to do this calculation from the data tier class i cant get the information to pass to the text box in my reservation form.

here is the code below for my data tier class
vb.net Code:
  1. Public Class DataTier
  2.     Dim fineprice As Long
  3.     Private Const mindays As Long = 0
  4.     Sub New(ByVal duedatesub As Date, ByVal returndatesub As Date)
  5.  
  6.         duedatepro = duedatesub
  7.         returndatepro = returndatesub
  8.     End Sub
  9.     Private returndatepri As Date
  10.     Public Property returndatepro As Date
  11.         Get
  12.             Return returndatepri
  13.         End Get
  14.         Set(value As Date)
  15.             returndatepri = value
  16.         End Set
  17.     End Property
  18.     Private duedatepri As Date
  19.     Public Property duedatepro As Date
  20.         Get
  21.             Return duedatepri
  22.         End Get
  23.         Set(value As Date)
  24.             duedatepri = value
  25.         End Set
  26.     End Property
  27.     Private finepri As Decimal = 2.5
  28.     Public Property finepro As Decimal
  29.         Get
  30.             Return finepri
  31.         End Get
  32.         Set(value As Decimal)
  33.             finepri = value
  34.         End Set
  35.     End Property
  36.  
  37.     Private daysoverduepri As Long
  38.     Public Property daysoverduepro As Long
  39.         Get
  40.             Return daysoverduepri
  41.         End Get
  42.         Set(value As Long)
  43.             'If value > mindays Then
  44.             daysoverduepri = value
  45.             'End If
  46.  
  47.         End Set
  48.     End Property
  49.     Dim diff As Long
  50.     Public Sub Daysoverduecal()
  51.  
  52.         diff = DateDiff(DateInterval.Day, CLng(duedatepro.Day), CLng(returndatepro.Day))
  53.  
  54.  
  55.     End Sub
  56.     Public ReadOnly Property Daysoverdueprocal As Long
  57.         Get
  58.             Return diff
  59.         End Get
  60.     End Property
  61.     Public ReadOnly Property finepreicepro As Long
  62.         Get
  63.             Return fineprice
  64.         End Get
  65.     End Property
  66. End Class

Here is the information from my reservation Form class

vb.net Code:
  1. Public Class Reservation_Table
  2.     Dim daysoverdue As Long
  3.     Dim fine As Decimal = 2.5
  4.  
  5.     Private Shared instance As Reservation_Table
  6.     Public Shared ReadOnly Property ReservationTableInstance() As Reservation_Table
  7.         Get
  8.             If instance Is Nothing Then
  9.                 instance = New Reservation_Table
  10.             End If
  11.             Return instance
  12.         End Get
  13.     End Property
  14.     Private Sub ReservationTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ReservationTableBindingNavigatorSaveItem.Click
  15.         Try
  16.  
  17.             Dim datatiercal As DataTier = New DataTier(Due_dateDateTimePicker.Value.Date, Return_dateDateTimePicker.Value.Date)
  18.             DayOverduetextbox.Text = datatiercal.Daysoverdueprocal
  19.             Me.Validate()
  20.             Me.ReservationTableBindingSource.EndEdit()
  21.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  22.  
  23.         Catch ex As Exception
  24.             MessageBox.Show(ex.Message)
  25.         End Try
  26.     End Sub
  27.  
  28.     Private Sub Reservation_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  29.         Try
  30.             'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.ReservationTable' table. You can move, or remove it, as needed.
  31.             Me.BookTableTableAdapter1.Fill(Me.Librarymanagementdatabase2DataSet.BookTable)
  32.             Me.ReservationTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.ReservationTable)
  33.         Catch ex As Exception
  34.             MessageBox.Show(ex.Message)
  35.         End Try
  36.     End Sub
  37.  
  38.     Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
  39.         Try
  40.             ReservationTableBindingSource.AddNew()
  41.             CostTextBox.Text = fine * daysoverdue
  42.             CostTextBox.Text = FormatCurrency(CostTextBox.Text)
  43.         Catch ex As Exception
  44.             MessageBox.Show(ex.Message)
  45.         End Try
  46.  
  47.     End Sub
  48.  
  49.     Private Sub SaveButton_Click_1(sender As Object, e As EventArgs) Handles SaveButton.Click
  50.         Try
  51.             Me.Validate()
  52.             FormatCurrency(CostTextBox.Text)
  53.             CostTextBox.Text = fine * daysoverdue
  54.             ReservationTableDataGridView.Columns(7).DefaultCellStyle.Format = "c"
  55.             Me.ReservationTableBindingSource.EndEdit()
  56.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  57.         Catch ex As Exception
  58.             MessageBox.Show(ex.Message)
  59.         End Try
  60.     End Sub
  61.  
  62.     Private Sub Reservation_Table_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
  63.         instance = Nothing
  64.     End Sub
  65.     Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click
  66.         Try
  67.             ReservationTableBindingSource.RemoveCurrent()
  68.         Catch ex As Exception
  69.             MessageBox.Show(ex.Message)
  70.         End Try
  71.     End Sub
  72.  
  73.     Private Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click
  74.         Try
  75.             Me.Validate()
  76.             FormatCurrency(CostTextBox.Text)
  77.             CostTextBox.Text = fine * daysoverdue
  78.             ReservationTableDataGridView.Columns(7).DefaultCellStyle.Format = "c"
  79.             Me.ReservationTableBindingSource.EndEdit()
  80.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  81.         Catch ex As Exception
  82.             MessageBox.Show(ex.Message)
  83.         End Try
  84.     End Sub
  85.  
  86.     Private Sub RenewButton_Click(sender As Object, e As EventArgs) Handles RenewButton.Click
  87.         Due_dateDateTimePicker.Value = Due_dateDateTimePicker.Value.Date.AddDays(7)
  88.         Return_dateDateTimePicker.Value = Due_dateDateTimePicker.Value.Date
  89.     End Sub
  90.  
  91.     Private Sub SearchToolStripButton_Click(sender As Object, e As EventArgs) Handles SearchToolStripButton.Click
  92.         Try
  93.             Me.ReservationTableTableAdapter.Search(Me.Librarymanagementdatabase2DataSet.ReservationTable, ReserverNameToolStripTextBox.Text)
  94.         Catch ex As System.Exception
  95.             System.Windows.Forms.MessageBox.Show(ex.Message)
  96.         End Try
  97.  
  98.     End Sub
  99. End Class

Here is the part of the code from the data tier that isn't working i cant get the datediff method to work. when i place a break it shows that the variable diff which is suppose to find the different between the dates is 0. i dont know how to get it to find the difference between the two dates.

vb.net Code:
  1. Dim diff As Long
  2.     Public Sub Daysoverduecal()
  3.         diff = DateDiff(DateInterval.Day, CLng(duedatepro.Day), CLng(returndatepro.Day))
  4.     End Sub
  5.     Public ReadOnly Property Daysoverdueprocal As Long
  6.         Get
  7.             Return diff
  8.         End Get
  9.     End Property

Access doesn't recognize saved textbox input

$
0
0
When I set the Default Value of the field in access to 0 for the FID field, the data will be saved successfully but it always show 0

The Member's name data is saving but the FID data does not



Name:  help.jpg
Views: 19
Size:  25.6 KB
Name:  codes.jpg
Views: 14
Size:  18.6 KB

Can somebody help me please? Thanks
Attached Images
  

Sending Email through outlook to email in cell in datagrdiview

$
0
0
Hi,

please can you help please to send Email through outlook to email in cell in datagrdiview,
I have a datagridview from Ms Access db and emails in one of the columns,
I would like to send Email like a reminder to those emails in the cells in the datagrdiview if the status of the item is open,

I wish you could help me with is, I am struggling with it.

network socket transfer from vb6.0 to VS2012

$
0
0
Guys, I'm stuck... I have a client app that I use to connect to my WiFi LAN Ctlr for adding users... it uses telnet normally. The app in vb6 works fine. But as I have to migrate to .net platform, I found no help in searching as everyone of the example comes up with nothing or a "??".

I tried all of these:

https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

http://www.vbforums.com/showthread.p...ction-commands

and no lock at all...

Basically my app takes the user ID, user passoword and then on click of a buttton, it will initiate a connection to the WLC at port 23 and will send WLC user/pass for login as admin and then it will send the commands "ADD USER userid WITH PASS password FOR WLAN mywlannet DURATION 8600"
And also for a confirmation, it will read the ADDED USER or it will print the telnet responses to the txtdebug text box.

upon submiting, it will automatically disconnect the telnet session but keep the data on screen. It will also make a printout in a slip. So, forget about the printer issue, all I need is telnet access to my WLC.
Mishu~

program to search through an outlook mailbox by Name or Subject Field

$
0
0
Hi VB Forums,

thanks for all your help last time.
I find myself stuck with an issue. we are automating our processes here and as part of that i am attempting to write a small app that will search through a mailbox by name (email address) and or Subject field.

i'm not sure where to start. any suggestions?
I will be looking through the forums in the meantime but id rather ask the experts 1st.

appreciate it so much guys

Grif

Use the toolbar dropdown menu as a popup menu?

$
0
0
Here is the thing:

There are two windows Form1 and Form2, and each form has a popup menu.
(1) Form1.show vbModal
(2) In Form1, Right-Click to popup a menu and excute a menu-command to show Form2.
In this case, the popup menu in Form2 is invalid (Right-Click is not valid).

Can we use the toolbar dropdown menu as a popup menu? That is, popup the toolbar dropdown menu at the mouse-down point when I right-click the form.
Attached Images
 
Attached Files

[RESOLVED] Need help passing values from one class to another

$
0
0
I have a class called data tier class where i am trying to pass the calculations from my daysoverdueprocal() method to the text box in my reservation form. The method daysoverdueprocal() is suppose to calculate the difference between the dates in my reservation form from my data tier class then place the answer into the text box in my reservation form. I can easily do all of this work in the reservation form and it will work but when i try to do this calculation from the data tier class i cant get the information to pass to the text box in my reservation form.

here is the code below for my data tier class
vb.net Code:
  1. Public Class DataTier
  2.     Dim fineprice As Long
  3.     Private Const mindays As Long = 0
  4.     Sub New(ByVal duedatesub As Date, ByVal returndatesub As Date)
  5.  
  6.         duedatepro = duedatesub
  7.         returndatepro = returndatesub
  8.     End Sub
  9.     Private returndatepri As Date
  10.     Public Property returndatepro As Date
  11.         Get
  12.             Return returndatepri
  13.         End Get
  14.         Set(value As Date)
  15.             returndatepri = value
  16.         End Set
  17.     End Property
  18.     Private duedatepri As Date
  19.     Public Property duedatepro As Date
  20.         Get
  21.             Return duedatepri
  22.         End Get
  23.         Set(value As Date)
  24.             duedatepri = value
  25.         End Set
  26.     End Property
  27.     Private finepri As Decimal = 2.5
  28.     Public Property finepro As Decimal
  29.         Get
  30.             Return finepri
  31.         End Get
  32.         Set(value As Decimal)
  33.             finepri = value
  34.         End Set
  35.     End Property
  36.  
  37.     Private daysoverduepri As Long
  38.     Public Property daysoverduepro As Long
  39.         Get
  40.             Return daysoverduepri
  41.         End Get
  42.         Set(value As Long)
  43.             'If value > mindays Then
  44.             daysoverduepri = value
  45.             'End If
  46.  
  47.         End Set
  48.     End Property
  49.     Dim diff As Long
  50.     Public Sub Daysoverduecal()
  51.  
  52.         diff = DateDiff(DateInterval.Day, CLng(duedatepro.Day), CLng(returndatepro.Day))
  53.  
  54.  
  55.     End Sub
  56.     Public ReadOnly Property Daysoverdueprocal As Long
  57.         Get
  58.             Return diff
  59.         End Get
  60.     End Property
  61.     Public ReadOnly Property finepreicepro As Long
  62.         Get
  63.             Return fineprice
  64.         End Get
  65.     End Property
  66. End Class

Here is the information from my reservation Form class

vb.net Code:
  1. Public Class Reservation_Table
  2.     Dim daysoverdue As Long
  3.     Dim fine As Decimal = 2.5
  4.  
  5.     Private Shared instance As Reservation_Table
  6.     Public Shared ReadOnly Property ReservationTableInstance() As Reservation_Table
  7.         Get
  8.             If instance Is Nothing Then
  9.                 instance = New Reservation_Table
  10.             End If
  11.             Return instance
  12.         End Get
  13.     End Property
  14.     Private Sub ReservationTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ReservationTableBindingNavigatorSaveItem.Click
  15.         Try
  16.  
  17.             Dim datatiercal As DataTier = New DataTier(Due_dateDateTimePicker.Value.Date, Return_dateDateTimePicker.Value.Date)
  18.             DayOverduetextbox.Text = datatiercal.Daysoverdueprocal
  19.             Me.Validate()
  20.             Me.ReservationTableBindingSource.EndEdit()
  21.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  22.  
  23.         Catch ex As Exception
  24.             MessageBox.Show(ex.Message)
  25.         End Try
  26.     End Sub
  27.  
  28.     Private Sub Reservation_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  29.         Try
  30.             'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.ReservationTable' table. You can move, or remove it, as needed.
  31.             Me.BookTableTableAdapter1.Fill(Me.Librarymanagementdatabase2DataSet.BookTable)
  32.             Me.ReservationTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.ReservationTable)
  33.         Catch ex As Exception
  34.             MessageBox.Show(ex.Message)
  35.         End Try
  36.     End Sub
  37.  
  38.     Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
  39.         Try
  40.             ReservationTableBindingSource.AddNew()
  41.             CostTextBox.Text = fine * daysoverdue
  42.             CostTextBox.Text = FormatCurrency(CostTextBox.Text)
  43.         Catch ex As Exception
  44.             MessageBox.Show(ex.Message)
  45.         End Try
  46.  
  47.     End Sub
  48.  
  49.     Private Sub SaveButton_Click_1(sender As Object, e As EventArgs) Handles SaveButton.Click
  50.         Try
  51.             Me.Validate()
  52.             FormatCurrency(CostTextBox.Text)
  53.             CostTextBox.Text = fine * daysoverdue
  54.             ReservationTableDataGridView.Columns(7).DefaultCellStyle.Format = "c"
  55.             Me.ReservationTableBindingSource.EndEdit()
  56.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  57.         Catch ex As Exception
  58.             MessageBox.Show(ex.Message)
  59.         End Try
  60.     End Sub
  61.  
  62.     Private Sub Reservation_Table_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
  63.         instance = Nothing
  64.     End Sub
  65.     Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click
  66.         Try
  67.             ReservationTableBindingSource.RemoveCurrent()
  68.         Catch ex As Exception
  69.             MessageBox.Show(ex.Message)
  70.         End Try
  71.     End Sub
  72.  
  73.     Private Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click
  74.         Try
  75.             Me.Validate()
  76.             FormatCurrency(CostTextBox.Text)
  77.             CostTextBox.Text = fine * daysoverdue
  78.             ReservationTableDataGridView.Columns(7).DefaultCellStyle.Format = "c"
  79.             Me.ReservationTableBindingSource.EndEdit()
  80.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  81.         Catch ex As Exception
  82.             MessageBox.Show(ex.Message)
  83.         End Try
  84.     End Sub
  85.  
  86.     Private Sub RenewButton_Click(sender As Object, e As EventArgs) Handles RenewButton.Click
  87.         Due_dateDateTimePicker.Value = Due_dateDateTimePicker.Value.Date.AddDays(7)
  88.         Return_dateDateTimePicker.Value = Due_dateDateTimePicker.Value.Date
  89.     End Sub
  90.  
  91.     Private Sub SearchToolStripButton_Click(sender As Object, e As EventArgs) Handles SearchToolStripButton.Click
  92.         Try
  93.             Me.ReservationTableTableAdapter.Search(Me.Librarymanagementdatabase2DataSet.ReservationTable, ReserverNameToolStripTextBox.Text)
  94.         Catch ex As System.Exception
  95.             System.Windows.Forms.MessageBox.Show(ex.Message)
  96.         End Try
  97.  
  98.     End Sub
  99. End Class

Here is the part of the code from the data tier that isn't working i cant get the datediff method to work. when i place a break it shows that the variable diff which is suppose to find the different between the dates is 0. i dont know how to get it to find the difference between the two dates.

vb.net Code:
  1. Dim diff As Long
  2.     Public Sub Daysoverduecal()
  3.         diff = DateDiff(DateInterval.Day, CLng(duedatepro.Day), CLng(returndatepro.Day))
  4.     End Sub
  5.     Public ReadOnly Property Daysoverdueprocal As Long
  6.         Get
  7.             Return diff
  8.         End Get
  9.     End Property

Use the toolbar dropdown button as a popup menu?

$
0
0
Here is the thing:

There are two windows Form1 and Form2, and each form has a popup menu.
(1) Form1.show vbModal
(2) In Form1, Right-Click to popup a menu and excute a menu-command to show Form2.
In this case, the popup menu in Form2 is invalid (Right-Click is not valid).

Can we use the toolbar dropdown button as a popup menu? That is, popup the toolbar dropdown button(menu) at the mouse-down point when I right-click the form.

Edit:
For better compatibility, I've changed the version of mscomctl.ocx in the test project from V2.2 to V2.0
Attached Images
 
Attached Files

Remote sharing shows only specific application

$
0
0
As title, I would like to write a program sharing only specific application ,not full desktop, from server to client such that client's control is limited.I found source code project for sharing desktop,how do I start the programming.Could anyone suggest API for this?

VS 2015 Help! Datagridview filter data in a range

$
0
0
I'm looking for the ability to filter data in a range
I made a test file to show the problem testfind.zip
Any ideas? :)
Attached Files

[RESOLVED] HLS Hue values?

$
0
0
I have a couple of weird problems here.

The idea is to load an image (included, thus the large attachment size) and convert it to black and white monochrome where "orange" pixels become white.


Issue #1:

I have some sort of logic error or something, because I have to "fudge" the hue range for "orange" to get a halfway decent result.

From within Converter.cls:

Code:

'HLS values are from 0 to 240.
'Hue range to change to white:
Private Const MIN_HUE As Integer = 100 '15 <-should be  'Min "orange" value.
Private Const MAX_HUE As Integer = 170 '35 <-should be  'Max "orange" value.
'Luminance minimum:
Private Const MIN_LUM As Integer = 100

Code:

            If Luminance >= MIN_LUM And (MIN_HUE <= Hue And Hue <= MAX_HUE) Then
                MonoPixel = 1
            Else
                MonoPixel = 0
            End If

The range should be 15..35 but by fiddling I find 100..170 at least gets me a sort of result that is almost right.

Why? "If" statement incorrect?


Issue #2:

In the IDE (but not when compiled) I get a crash if I delete the line:

Code:

    Const THRESHOLD As Byte = 0
... in Converter.MonoPicture() for some strange reason.

This was a leftover constant from another version of the class, and it is not used at all in this version.

Weird!
Attached Files

VB.NET - Simple Database Connection

$
0
0
This simple class helps in running commands in a MS SQL database. It requires a connection string, and RunCommand and RunCommandAsync require a string parameter to use as the command.

What's my connection string?

Code:

''' <summary>
''' Allows easy access to a database.
''' </summary>
Public Class DatabaseManager

    Private SqlConnection As SqlClient.SqlConnection
    Private SqlCommand As SqlClient.SqlCommand
    Private SqlReader As SqlClient.SqlDataReader

    ''' <summary>
    ''' Creates a new connection to a database using the provided connection string.
    ''' </summary>
    Public Sub New(ConnectionString As String)
        SqlConnection = New SqlClient.SqlConnection(ConnectionString)
    End Sub

    ''' <summary>
    ''' Synchronously runs an SQL command.
    ''' </summary>
    Public Function RunCommand(CommandString As String) As List(Of List(Of Object))
        SqlConnection.Open()
        SqlCommand = New SqlClient.SqlCommand(CommandString, SqlConnection)
        SqlReader = SqlCommand.ExecuteReader()
        Dim Returns As New List(Of List(Of Object))
        While SqlReader.Read()
            Returns.Add(New List(Of Object))
            For i As Integer = 0 To SqlReader.FieldCount - 1 Step 1
                Returns(Returns.Count - 1).Add(SqlReader.Item(i))
            Next
        End While
        SqlConnection.Close()
        Return Returns
    End Function

    ''' <summary>
    ''' Asynchronously runs an SQL command.
    ''' </summary>
    Public Async Function RunCommandAsync(CommandString As String) As Task(Of List(Of List(Of Object)))
        Await SqlConnection.OpenAsync()
        SqlCommand = New SqlClient.SqlCommand(CommandString, SqlConnection)
        SqlReader = Await SqlCommand.ExecuteReaderAsync()
        Dim Returns As New List(Of List(Of Object))
        While SqlReader.Read()
            Returns.Add(New List(Of Object))
            For i As Integer = 0 To SqlReader.FieldCount - 1 Step 1
                Returns(Returns.Count - 1).Add(SqlReader.Item(i))
            Next
        End While
        SqlConnection.Close()
        Return Returns
    End Function

End Class

Usage:

Code:

    Private Sub SomeSqlFunction()

        DBM = New DatabaseManager("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;")
        DBM.RunCommand("CREATE TABLE People (LName varchar(255), FName varchar(255), MInitial varchar(255));")
        DBM.RunCommand("INSERT INTO People (LName, FName, MInitial) VALUES ('Johnson', 'Bill', 'H');")
        DBM.RunCommand("INSERT INTO People (LName, FName) VALUES ('Miller', 'Alex');")
        Dim Result As List(Of List(Of Object)) = DBM.RunCommand("SELECT * FROM People")

        ' Displaying the contents.
        Dim MessageString As String = ""
        For Each R In Result
            For Each C In R
                MessageString &= $"{C.ToString()} "
            Next
            MessageString &= Environment.NewLine
        Next
        MessageBox.Show(MessageString)

    End Sub

Best of luck,
~Nic

[vb6] Sharing Sample Projects that Include Common Controls

$
0
0
This thread is only pertinent if you are using the Windows common controls in your project.

There are at least three versions of the common controls floating around. Depending on which you have referenced in your project and which exists on the downloader's PC, the project may fail to open. The person downloading your code likely falls into two categories: a) your code stinks and is broken and was a waste of time downloading it, or 2) confused.

How to address this problem? First, open your intended upload's vbp file in NotePad. Find the line near the top that references the common controls, it will look like one of the following:

Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; mscomctl.OCX
or (shouldn't be including both)
Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; comctl32.Ocx

If your project's version numbers are the same as those above (in bold), no problems should be experienced by anyone downloading your sample project. But if they are not the same, then problems can occur if the user's version is older than yours. In that case, the user is told that the project could not load the referenced library/ocx. Additionally, if the user continues to load the project, all your common controls (treeview/listviews for example) become picture boxes and when user tries to run the project, errors galore.

To prevent that problem, you could simply modify that line to replace the newer version number with the appropriate one above. This does nothing to your project on your system. When you open your project and later save it, the version changes back to what it was. But this is important: The line you want to modify exists in the vbp file and each .frm, .ctl and .ppg file that uses those controls. The entry you will be looking for is also near the top of those files. It doesn't hurt to double check other project files just in case I missed listing one of their extensions.

For those downloading your sample project, any newer version the user may have will be used. Only when their version is older than the one listed in the project, will there be a problem for them. Luckily, so far, the different versions remain binary compatible with each other.

FYI: The version installed on any PC is due to SP6 and/or one of its security patches, possibly by other Microsoft software you've installed or maybe even Windows updates. Asking people to install the most recent SP6 security-patch to make their version the same as yours is typically not an option.
Viewing all 42269 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>