Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
edmund745
Jun 5, 2010
Not a professional programmer, just messing around on my own: I have noticed that there's two ways to declare arrays in vb.net:

Dim arrayOfNames() as String

Dim arrayOfNames as String()



Either works, I'm not complaining,,,,,,, but ......why?

I would guess that one is a newer/standardized way, and the other is a hold-over from ancient previous versions...?

Adbot
ADBOT LOVES YOU

edmund745
Jun 5, 2010
I have a vb.net question about the calendarcontrol--is there any way to get rid of the blue highlighted [current] date until the user clicks on the calendar at least once?



I am using it to select a weekly schedule to open. I could make it work like it is, but I'd prefer it if I could just turn that off initially.

I tried setting the selectionrange to zero (initially) but it won't accept that.

edmund745
Jun 5, 2010
Another VB.net question: does file path capitalization matter?

As I said a ways back, I have a monthcalendar the user clicks on, that is supposed to open the file for that week. To get the path to the exe's own location, the program gets the System.AppDomain.CurrentDomain.BaseDirectory string, adds on the couple other folders and the filename, and then,,,,,,, doesn't work.

So I put in a button that calls an OpenFileDialog to get the path, and then does everything else the same, and the program using OpenFileDialog,,, works just fine.

I have checked everything else over, and can't find any difference. When I compared the paths that the two different ways generated, I found that they were not the same (see below, and ignore the missing end part).



The top one is what the PC shows all the rest of the time (Win 7 x64, automatic updates on, and I only downloaded VB.net a couple weeks ago)
I have looked at everything else a LOT, and cannot find any other differences in what the code does. I've even wrote little test stubs and the literal path from the OpenFileDialog works 100%, no matter how its called--and the uncapitalized path from the System.AppDomain.CurrentDomain.BaseDirectory doesn't work, at all...... ?

If there was a way to use relative filepaths I would, but (according to what I've found online) they either aren't supported or are depreciated in VB.net. Is there another way to do this?

edmund745 fucked around with this message at 02:18 on Apr 1, 2012

edmund745
Jun 5, 2010

Ithaqua posted:

Of course relative file paths are supported. I don't know where you read that.
I couldn't find any examples that were for vb.net. It seems there's a lot of people out there still rocking it with VB.3/4/5/6, even in the last few years.... ?:| ...After multiple attempts with no success, I gave up trying to use any examples from earlier versions in VB.net.

quote:

That said, you say it "doesn't work". What do you mean by that? Does it throw an exception?
When it doesn't work,,, nothing happens. No error message, no file opens. Nothing. No data file ever loads.
When I opened a file using the OpenFileDialog, the data file opened in the program right away, and worked normally.
------
I did switch to using the path.getfullpath method instead, and it works (with the calendar control):
http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath%28v=VS.90%29.aspx

I found the System.AppDomain.CurrentDomain.BaseDirectory on another MSDN page that I cannot re-locate now. There seem to be a number of ways to "get a path to a file or directory", all with subtle differences. I'm not sure what the point is though if the path isn't functional. The example on that page was on the "VB.net" tab, so I guess its good for ?something?

quote:

That said, you might want to consider using a database for storing information, not flat files.
I thought about that, what with the drag&drop datagrids and all--but I decided that the capabilities of the data components wasn't really useful for ways I needed to use the info.

edmund745
Jun 5, 2010
By the by, does VB.net automatically cast back and forth between checkstates and boolean values?

Some of the earlier versions seemed to, but all the .net stuff I can find no longer mentions it.

edmund745
Jun 5, 2010
Today it is graphics.......

I am writing a VB.net program that draws some interactive images to a [public] bitmap (on a module) and then displays them in a picturebox.

I can put all the GDI stuff in a {Using,,,, End Using} statement so the graphics is disposed in the sub that does the drawing. Where should the bitmap be disposed? I am guessing,,, in the program's main FormClosed event?

The bitmap must be used the entire time the program is running. I've already seen that if I dispose it when it is in a picturebox, that triggers a break on an invalid parameter reference.


(.....I am using a bunch of public variables on the module already-- I never got the hand of encapsulating everything, and I'm just doing this for fun anyway)

edmund745
Jun 5, 2010
Okay here is a vb.net graphics trivia question for y'all. It is no longer a problem because I already found the solution (which I will relate) but still a question remains:

I needed to draw an image with text--so I made a picturebox, set the background to white, set up a bitmap to draw on, drew some test lines and text on the bitmap, and sent the bitmap to the picturebox. A screencap of that is below-



All of the above examples were with the FontStyle set to regular, NOT bold.

My PC has Win7, but the program I am writing will probably end up on computers running WinXP. I found that the "MS UI Gothic" looked just fine, but that it was not present on WinXP, so I began testing other fonts and fontfamilies that could carry over.... And they all looked like crap. I know a couple things about fonts, and it appears as though the hinting is not being used properly in all but the top one.

Well I looked around and found this page-
http://stackoverflow.com/questions/3418283/graphics-drawstring-looks-nice-in-picturebox-but-horrible-in-a-bitmap

-where somebody else had a similar problem, and someone there put a link to this page-
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/9a66c7a2-79ad-4c9b-91cc-361ec72d13de
-that gives the solution: when you try to render text onto a bitmap that has a transparent background, there is no background color for the font's hinting to dither to. So first you need to set the bitmap's background color to [something other than transparent], and then any font you use should hint properly.



But one question still remains.......



Why did the MS UI Gothic font look PERFECT, even when there was no background color for it to dither to? I tried a bunch of different fonts before finding out about the background color issue, and MS UI Gothic was the ONLY font that looked right against a transparent background....?

I have not found any info that says the OS considers it to be any different than other fonts.... Most information I find about it only says that it is a standard Win7 kanji font. The Microsoft page even shows the example in kanji.
http://www.microsoft.com/typography/fonts/font.aspx?FMID=1612

edmund745
Jun 5, 2010
Below is a screencap of the difference (after coloring the bitmap background white).
Also by zooming in it is demonstrated that the MS UI Gothic font looks clearer, because it is acting like a bitmap font--it isn't dithering at all?



(I changed the text on the last line, but none of them look like crap here. They all look like they're supposed to...)

edmund745
Jun 5, 2010
I have a VB.net program where I am drawing charts on a bitmap and displaying it in a picturebox. The chart is much wider than the picturebox, so I have buttons to scroll the view left-and-right, by using a variable in all the horizontal points, and changing the value of that variable. (before the buttons, I had a Hscrollbar, then I tried a trackbar, and they showed the same issue).

The problem that I am seeing is that when the rectangle points are moved left-or-right (by any of the three controls) the coordinate point moves the correct amount, but the width increases +1 interval, in whichever direction it is moved. Both the coordinate point and the height/width point are changed by the same variable-

code:
'gray-out [yesterday]
g.FillRectangle(brushLightGray, (162 - bakeryVOffSet), gridLineTop, (624 - bakeryVOffSet), (gridLineBottom - 4))
'gray-out [tomorrow]
g.FillRectangle(brushLightGray, (1876 - bakeryVOffSet), gridLineTop, (2344 - bakeryVOffSet), (gridLineBottom - 4))

(bakeryVOffSet is the variable that is used to change both points here...)
I have tried DrawRectangle and had the same result==the right edge of the rectangle moves.

I was just drawing the entire chart, even though 2/3 of it was outside the view. I didn't find any info that said this was a particularly error-prone practice. And the width-shifting occurs even if both ends of the rectangle are within the bitmap/picturebox bounds anyway.
Is there a workaround to this?
I could rewrite the whole thing to avoid the drawing-off-bitmap issue but I don't know that it will make any difference.

edmund745
Jun 5, 2010

Ithaqua posted:

Did you try putting your control inside a Panel, rendering the entire image in the picturebox, and setting the panel's autoscroll property to true?
Yea, that's how I was doing the vertical scrolling. I couldn't use it for the horizontal scrolling since some of the displayed chart had to always be visible.

pics here:
http://www.norcom2000.com/users/dcimper/assorted/inanities/general_wtf/scroll/troubles.html

I changed the scroll method to another way that works (and that avoids drawing off the screen entirely) and the #1 pic is a couple screenshots of that. The top (title) area, the left name column and the right two columns (marked in red) always need to be visible, but the center 12-hour divisions need to range over 3 PM the previous day, to 9 AM the day after.

The gray blocks represent where the preceding day ends and the following day begins. Plus all the other stuff will be represented as colored rectangles too.

--------

What I WANTED to do originally,,, is shown by the second pic. This would have been a much simpler method, if the fillrectangle function would have worked right. I wanted to draw the entire chart (even though most of it would not be visible), control what part was visible (within the purple frame) by using the offset variable for all the coordinates and points, and then draw the top, left and right columns afterward using fixed coordinates + points.

And that's what didn't work.
Every method for drawing a rectangle fails if shifted by a variable, as far as I can tell. If I shifted BOTH the coordinate and the point by a value (say ten pixels), the coordinate shifts 10 pixels like you'd expect, but the other point shifts 10+10 pixels, in whatever direction you changed it. If you shift it again, the coordinate shifts another 10 pixels (correctly) but then the point shifts 10+20 pixels.

I could have coded something to accommodate for this maybe, but then that would have kinda blown the whole simplicity of the method.

???
I tried several different ways of drawing filled and unfilled rectangles, and all of them displayed this shifting error. And in the code I have, the ONLY variable value that changes, changes the same for both points? (it's the same variable)

edmund745
Jun 5, 2010

Jabor posted:

Here's what you're missing: When you draw a rectangle, you don't give it two points.

You give it a point, and a size. If you want to change where it is without changing how big it is, offset the point without touching the size.
:headsmack:
Well sure..... it seems so simple if you say it that way. :|
{It had been a long night at the keyboard}

--------

I'm doing much better today-
http://www.norcom2000.com/users/dcimper/assorted/inanities/general_wtf/scroll/scroller_better_5743.png
I still don't have the mouse-click-editing ability in, but displaying them properly is working (though not complete yet). The add/delete/edit employees parts work, the schedule-generator works (weekly schedules with automatically-generated filenames, always ending on Friday) and the different departments list the employees correctly (dept manager, asst manager, full-timers by seniority, part-timers by seniority). The name row the pointer is in highlights red and the different shift types show up as different colors, and scroll properly left-and-right. :D

edmund745
Jun 5, 2010
It's time for "dummies on parade" again: in vb.net, what would cause subroutine calls in a form load() event not to run?

I have a separate form (not the main form) that is supposed to call a sub (on a public module) to print a little report into a textbox on the form--and nothing I have tried will work. I've done this 100 times before and not ever had any problemst. I have tried putting messagesboxes everywhere, on everything, to make sure that everything necessary is happening, and it is,,,,,,,,,,, but the textbox still remains blank. I have tried concatenating the report text into a separate string variable, and then just giving that to the textbox--and still, nothing. I have even deleted the textbox and re-created another, with another name, to make sure I hadn't altered some setting on it I didn't know about. And the new textbox still remains blank.

This is the form load() content-

code:
Private Sub departmentForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        changeDeptNamesComboBox.Items.AddRange(departmentNamesArray) '<--------this works, 100%, every time???

        'MsgBox("before calling showDeptNamesReport()")  '<----------this works, if it isn't commented out
        showDeptNamesReport() '<---------------------------------------------this sub call works, but the sub itself never does 
        'MsgBox("after calling showDeptNamesReport()")   '<----------this works, if it isn't commented out

    End Sub
This is the subroutine content:

code:
 Public Sub showDeptNamesReport()
        'this shows a textbox summary report of the department names in deptNamesTextbox on departmentForm1 

        departmentForm1.deptReportTextBox.Text = "" '<----the textbox has some default text that this is supposed to wipe out, but this never works
        '                                                 (the textbox has the text "-empty-" set in the properties, just to see if it ever changes)

        departmentForm1.deptReportTextBox.Text = "what2" & Environment.NewLine '<---------this is just a test line, but it doesn't ever get put in textbox?
        'MsgBox("in showDeptNamesReport") '<--------#1--------this msgbox works, 100% of the time
        For loop2 = 0 To 23
            departmentForm1.deptReportTextBox.Text = departmentForm1.deptReportTextBox.Text & "Department #" & Convert.ToString(loop2) & " --- " & departmentNamesArray(loop2) & Environment.NewLine '<---this don't work, ever???
            'MsgBox("reading :" & departmentNamesArray(loop2)) '<------#2-----this msgbox works perfectly, and goes through the array contents, 100% of the time
        Next

    End Sub
The thing I understand the least here is,,,,, there is a combobox, and a textbox, on this form. And BOTH are drawing their content from the same String array--departmentNamesArray(). The combobox is having ZERO problems, and the textbox remains blank, no matter what I do?

edmund745
Jun 5, 2010

Ithaqua posted:

Have you tried putting a breakpoint in and stepping through in a debugger?

Yea.
The first line (the one that loads the combobox) works, but the other call (to the subroutine) just gets skipped over? It doesn't go into it. It is ignoring the subroutine call,,,,, and this is the mystery.

I think that maybe the textbox isn't initialized or something? But there's no other place to put any calls to load 'starting conditions' for a form--like,,,,, loading text into a textbox. EVERYWHERE I am looking online, says to use the form_load()/mybase.load (which is the same thing)

edmund745
Jun 5, 2010

Zhentar posted:

Where is showDeptNamesReport() getting departmentForm1 from? Are you sure it's referencing the correct form?
departmentForm1 is the template name. the actual instance name didn't work, I tried it.

I DID get it to work, but I have no loving clue why. And it took about six hours.

First off, I rewrote the mysterious-nonfunctioning-subroutine into a function that returns the text in a string variable.

Secondly, I moved the line to load the combobox to LAST,,,,, and I don't know why that should make a difference. But when the debugger hits that line, it leaves the form_load() subroutine, and never comes back ???

code:
Private Sub departmentForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'changeDeptNamesComboBox.Items.AddRange(departmentNamesArray) '<--------the mystery diverter line?????

        deptReportTextBox.Text = ""
        deptReportTextBox.Text = showDeptNamesReportFunction() '<-----this returns the info as a string variable,,, and it works?

        changeDeptNamesComboBox.Items.AddRange(departmentNamesArray) '<--------mystery diverter line relocated
        

    End Sub
I would still really, really like to know why the sub wouldn't work. I have a dozen subs on the main form's onload() event, and all of them always worked 100%.

edmund745
Jun 5, 2010

prolecat posted:

The short version is that on 64-bit systems running 32-bit programs, exceptions during form load get silently swallowed. If this is what's happening, turning on break on thrown in the debugger will cause it to break when it happens.
How would I turn that on? There doesn't appear to be anything in the debugger options that looks like that. At the moment I don't have anything to catch ANY exceptions in the code (that would have been done last).

After getting some sleep and playing with this some more, it isn't any more clear which of the two matters (filling the combobox or putting text into the textbox) is causing the issue. It appears that both do.

I have gone to alternate methods for doing the same things, and they work--but alternating them with the other ways (and changing the order),,,, can cause ALL of them to not work? And no exceptions to be thrown, or errors reported.

code:
Private Sub departmentForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Note: departmentNamesArray() is a public/module string array with the department names already in it

        'changeDeptNamesComboBox.Items.AddRange(departmentNamesArray) '<--------wat #1? don't werk

        For aloop = 0 To 23 '<------------this works, but not if showDeptNamesReport() is called in front of it
            changeDeptNamesComboBox.Items.Add(departmentNamesArray(aloop))
        Next

        deptReportTextBox.Text = "" '<--------this works now, but may or may not work depending on what is placed before it
        'showDeptNamesReport() '<------------wat #2? (a sub that sends the departmentNamesArray() contents to deptReportTextbox,,, don't werk

        deptReportTextBox.Text = showDeptNamesReportFunction() '<---a function that returns the concatenated string contents from departmentNamesArray()
        '               ....this line [above] works, but not if " changeDeptNamesComboBox.Items.AddRange(departmentNamesArray) " is called before it


    End Sub
The funny part is, this is all that the form does. All it does is list the department names in the array, and allow editing them. I didn't have the real estate on the main form, so I thought it would be quick and easy to just stick this on a separate mini-form,,, and I jacked with this for at least six hours.

edmund745
Jun 5, 2010

prolecat posted:

Its under Debug->Exceptions. Check all the boxes under the Thrown heading. It's probably a CLR exception, but ticking them all won't hurt. After that, run and see if the debugger breaks. If so, you should at least get some clue what's going wrong.
I ain't got none.
Below shows three screencaps combined (the right is two, to show the entire list of debugger options).


I can't find any other place with technical settings for the debugger, at all. I am using the freebie version, maybe it is only in the paid version?

edmund745
Jun 5, 2010

prolecat posted:

For some reason the option isn't in your menu. Maybe that's a VB or Express version thing. There's information on adding it to the menu here, which the page says applies to VB Express: http://msdn.microsoft.com/en-us/library/d14azbfh.aspx
Okay, I did get it put into the menu now. It just wasn't there by default.

Thanks very much,,,,,, even though...... it may not make any difference. :D

edmund745
Jun 5, 2010
I have spent several hours again with yet another incomprehensible error in Visual Basic--where the [Microsoft] program is screwing up. Does it have a lot of these bugs?

I liked it because it is easy to use, but when I spend hours going in circles because it fucks up simple poo poo,,,,, I begin to wonder if there's anything else similar that is also free to use for non-commercial purposes.

edmund745
Jun 5, 2010

csammis posted:

What in the blue hell are you talking about? What's the [Microsoft] program? What errors are you getting?
The program is Visual Basic Express.

Today it was a table that would give out values that were different than the values that were put into it. It wasn't anything complicated in the least. It was loading some data into it with a loop, and then a little while later, trying to get the same values back out with another----and not getting the same values.

I (eventually) got around it by using four different arrays for the same data instead of one table. Using the separate arrays, the rest of the program works perfectly fine. ???? That shouldn't matter that I have ever read. It is possible I had something wrong in there--but then again, a x64 OS shouldn't be dropping x32 exceptions on form_load(), either. I spent about six hours thinking that was my fault. I guess spending only a couple hours on this is an improvement.

--------

Visual Studio and the Borland IDEs are the only two I've seen that I've liked really, I guess. I haven't tried any of the free ones for some years now. It would have to be C/C++; I find Java a bit tiring (encapsulating everything even for a dinky program, and that goofy "dock everything in everything" lay out manager).

edmund745
Jun 5, 2010
This isn't exactly a .net question, but it is on Windows and being done in vb.net, so anyway:

I am writing a program that will be installed on 2 or 3 separate computers on the same LAN. The program reads & writes to data files a lot--to make it simple to use, there is no [save] buttons at all. Any time you make a change that would warrant saving the file, it just goes and saves it.

The data files read & written to are centralized (they are the same files) for all three computers/instances of the program. Since there is no way to make everything work properly with more than one instance running, I need a way to only allow one instance to run.

I can see two ways right off:
1--have a single "lock" file and have the programs open it first for writing, and leave it open for writing the whole time the program is in use. Problem here is if the program crashes, the 'lock' file could (?) get left open+locked, and this is in a business setting where nobody will know how to deal with that.

2--have a "indicator" file that the programs all check inside for a status. If the file is blank, then it writes a status (such as which PC is already in use) and then immediately closes the file. As the software closes, it also un-writes the status file to blank. ......This could still have the issue of a "hung status", but that could be dealt with in the the software itself. This could just have a popup window that says to make sure that nobody else is on the other PCs, and then overwrite the hung status and start the program normally.

Which of these is the least-insane? I am thinking #2. Or is there a better way? The data files are flat/text files.

The machine OSs are WinXP.

edmund745 fucked around with this message at 22:40 on Aug 11, 2012

edmund745
Jun 5, 2010

Ithaqua posted:

Everything about what you're trying to do is asking for trouble. What's the actual use of these files? Why do they need to be changed from three locations? What about them makes them unable to be edited in parallel?
The program is a work shift scheduling utility. The data files are an employee list and weekly schedule files.

I want the program to be available on three separate computers, but they all need to reference the same data files.

If they attempt to edit the same things at once, that's going to cause issues since they may not see each other's edits--so I need to block the other two if any one PC/program is already in use.

quote:

It's very likely that there's a better solution to the problem. It probably involves not using flat files for storage, for starters.
I wanted files that were human-readable in case of problems during programming or in actual use. That alone rules out most of the usual suspects like database formats, serializing objects, ect.

Also it's not much data involved; 4-6kB per person, with a 150-person limit but probably only 75-100 people.

edmund745
Jun 5, 2010
I'm trying to get a vb.net program to be able to type into another program using Sendkeys. So far I can't even get a VB program to grab any foreground window other than itself, however. What is the secret here? So far I cannot find one easy-to-understand, working example of this (written in vb.net) online.

The example below works, but not really, because it only works when the VB program itself has focus--which is no help. When the vb program isn't in the foreground, the timer event doesn't seem to trigger at all, and yet everything I've read says that it should. What is wrong with it?

code:
Public Class KeySender01 '--the form

    Public loopCatcher As Boolean
    Public sendkeysTargetForm As Form


    Private Sub KeySender01_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        sendkeysTargetForm = Nothing
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        Timer1.Enabled = True '--timer1 interval set to 5000
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Enabled = False
        TextBox1.Text = Convert.ToString(sendkeysTargetForm)
    End Sub


    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wtf.Click, Timer1.Tick
        grabWindow()
    End Sub


    Private Sub grabWindow()
        sendkeysTargetForm = Form.ActiveForm
        'TextBox1.Text = ""
        'TextBox1.Text = Convert.ToString(sendkeysTargetForm)
    End Sub


End Class

edmund745
Jun 5, 2010

Ithaqua posted:

There has to be more code than that. The code you pasted shows literally nothing.

Well,,, the timer event is set to Button6_Click. I forgot to comment that on there.

That should be all it takes.... And it does work, when the vb program is in the foreground. The timer just doesn't work when its in the background. So maybe this is more of a timer question?

I have also tried putting timer1.start and timer1.stop in the buttons with the timer enable/disable, and it still does(n't) do the same thing. :\

edmund745
Jun 5, 2010

Jabor posted:

Where is the sending keys bit supposed to be happening?
The Sendkeys part isn't even in there yet. I would need to be able to grab the target window somehow before I could use Sendkeys. All that the code I posted is supposed to do is grab the foreground window every 5 seconds (even if its not in the foreground) and show the info in the textbox.

Here is another example I tried:
http://www.vbforums.com/showthread.php?281243-Get-Active-Control-Resolved&highlight=active (the example code given in post #10)

It works fine when the VB program has foreground, but when its in the background it raises an error about an "unbalanced stack". A number of the others I tried said the same thing.

edmund745
Jun 5, 2010
well nuts.
I been trying to find ONE working example of this for about three days now.
I finally come on here and ask, and about two minutes later find one that actually works:

http://www.vbforums.com/showthread.php?494477-Get-foreground-window-text

The code given in post #10 there does actually work. And doesn't crash the program or anything.

------

This has been a pain I think because a lot of examples aren't concerned with finding ANY foreground window,,, they just have a bunch of child windows, and are trying to find out which one the user is in.

edmund745
Jun 5, 2010

adaz posted:

Well I've had to do this before so you get lucky! There is probably a better way of doing this, but maybe not sending keys between different programs is pretty much always a kludge.
So do you call the method with a timer? I tried that and it doesn't work.

The vb program loses focus when the timer tics, but nothing appears in the target window (in this case, notepad--the only other window open).

edmund745
Jun 5, 2010

PhonyMcRingRing posted:

This doesn't do what you think it does. Form.ActiveForm gives you the currently active form in your application. It knows nothing about any outside application.
Yea I noticed that. It could be that there isn't any way left to do it in vb now.

Most of what I find is using C#, and using code that doesn't have an equivalent in vb.net. Of the 3 or 4 examples of on-screen keyboards that were written in vb, they were all for earlier versions of VB and none of them will work now.

edmund745
Jun 5, 2010

Zhentar posted:

Or tell us what you're actually trying to accomplish, and you may get more help.
I wanted a vb form sub or function to be able to get the previous foreground window, in a way that can be used with Sendkeys.
The sendkeys target will be ANOTHER totally-separate application, that I don't know any info on in advance. So it has to find it the way that an on-screen keyboard does--by identifying the previously-active window, of a separate application.
,,,,,,,
There is reasons it may not be workable with the target app anyway. I didn't expect it to be so difficult though.

When I said there may be "no way to do it", I meant no officially-supported way. While trying to figure out other versions of on-screen keyboards written in c# or C++, frequently there is calls they make that appear to have no VB equivalent (at least none given on the MSDN site).

I think I tried three different on-screen keyboards that were written in earlier versions of VB, and none of them will compile/run on vb.net at all. -And of the ones posted online, nobody seems to have written newer ones or updated older ones in a long time.

Also I noticed that a lot of the C# and C++ ones go into details about how to prevent the on-screen keyboard from stealing focus, by intercepting mouse messages. None of the (old) VB ones seem to bother with this, so that is another reason I think this isn't supported in VB anymore. Something seems to have changed between then and now... ?
One example (discussing focus-stealing and how to prevent it):
http://www.yortondotnet.com/2006/11/on-screen-keyboards.html

edmund745 fucked around with this message at 13:28 on Aug 29, 2012

edmund745
Jun 5, 2010

Munkeymon posted:

You keep saying 'old VB' - do you mean VB6? That's different from VB.Net and some of the things it does might not translate very well into .Net land.
Yes, older versions of VB. As in, VB6 or VB2008.
The examples of on-screen keyboard projects that I find online programmed in VB are all from older versions of VB, and there may be a reason for that. (I actually have a VB6 Pro install disk w/serial around somewhere, but I dun think I want to go that route at this point)

Zhentar posted:

Yes, but why do you want to do this? What goal do you hope to accomplish by doing this?
Because the VB program I am working on produces values that ultimately need to be entered into another program. The normal way they are entered is typing, so this would have been the easiest way to facilitate that without being able to test anything on that software directly. This is an unofficial/volunteer project of my own, and it is being kept secret to make it a surprise to the higher-up company people--so I don't have the ability to test it on the target software, nor do I know how else it might be entered.

In this use, it would need to [tab] between multiple text fields though,,,, so that's another reason that I am unsure if it would have worked. First I had planned to make a small Sendkeys-testing program that would just find the target program (the same way that on-screen keyboards find the previous-foreground window) and then send the key string {1[tab]2[tab]3[tab]4} just to see if it could get from one text field to the next properly.

edmund745
Jun 5, 2010
Let's say I had a vb.net program, that had a main form and two other forms, and I had textboxes on the two forms, and I wanted to send the text between them. What is the absolute-idiot-proof way I can do that, while knowing the least about overriding classes and events and so on?

I had this program I wrote that had a main form and a sub-form. Textboxes on the two would easily pass text back and forth to each other, the textbox modifiers didn't even have to be set to public.

Now I changed the program to have the main form, and two other sub-forms. The two sub-forms have the textboxes that always need to be the same. I can store the text value in a global variable and either form will load that correctly during their load() event, but I need an event I can call from each form to force the other to update, and I can't figure out what that is. Is there any?

Please note that about 95% of the examples online I find about passing data between forms is passing between the MAIN form and a child form. That ain't the problem here.
There is nice short little examples like this-
http://www.ehow.com/how_10015245_pass-data-between-multiple-forms-vbnet.html
but they are always passing values between the MAIN form and a sub-form. That method doesn't work between two sub-forms.

edmund745
Jun 5, 2010
One solution and one question.......

In a vb.net program I'm writing that draws a bunch of charts on bitmaps and displays them in pictureboxes/forms, for some reason one of the fonts I declared (as a regular fontstyle),,,, suddenly goes to bold fontstyle in the middle of the program.
???
What I found messing with it was that if I painted a white fillRectangle over the text area first, then the drawstring command goes back to printing text in regular style....... from them on. I dunno? The font is declared once (as a global) and it works 100% correct in every other instance it is used.

I have seen this problem mentioned a few times elsewhere, but the circumstances are different.
Some people do not paint the bitmap a base color before applying the text, and I knew about that already.
Some people get font weirdness when writing a program on one OS and then running on a different OS, but I am writing & running on the same Win7 PC.

-------

The question is about using the vb.net string.split() method. At one point I got the bright idea of using non-key characters (characters that non-techie people would never normally type) and so I randomly chose alt-20 {§} and alt-21 {¶} (some pages refer to these as the 'section' symbol and 'paragraph' symbol). And I found out that split() doesn't work {at all} with alt-21. Or does it?

I just assumed that maybe split() won't work with non-printing characters, but there are other reports that it does. Here is someone's account of using the section symbol-
http://stackoverflow.com/questions/1879860/most-reliable-split-character
When I switched the program to use the ` and ^ symbols instead, it worked perfectly.

I was trying to split a file that was written & read in text mode. Is there any restrictions about using non-printing characters in such a file? I casually looked around on the msdn site and could not find any.....

edmund745
Jun 5, 2010

ljw1004 posted:

I believe this is almost always due to running out of win32 GDI resources (brushes, pens, fonts, ...) And the solution is to be absolutely iron-clad sure that you're disposing each one as soon as you're done with it.
I do all the graphics stuff in using,,, end using statements. Do the pens and brushes still need to be disposed? I had read that they didn't.

(The bitmaps are sometimes used in multiple displays so they are left persistent intentionally--but there is only a few in use, referred to by specific names)

quote:

...I think you're more likely having a trouble with text-encoding. The paragraph marker isn't in the "!@#$%^1*()*+,-./0...9...A...a...z{|}~" range of standardised ascii. So if you have a non-unicode text document and load it in, it's hard to predict what the paragraph-mark will come back as.
I dunno. The file in question is one used by the program, and it is written and read in text-mode. :|

edmund745
Jun 5, 2010

Jabor posted:

Where did you read that? Pens and brushes are still GDI objects, so if you're creating new ones all the time and not cleaning them up then that will cause you to hit the handle limit.
It is my understanding that normally graphics objects are persistent and need to be disposed--(that is the reason for the dispose method being there)--but the using/end using statement also automatically disposes of anything declared inside it.
http://www.dreamincode.net/forums/topic/265854-dispose-method-in-using-statement/
Does msdn say either way? I could not find where either topic mentions the other.

ljw1004 posted:

Written and read in text-UTF8? text-UTF16? Some text-ASCII encoding? If so which codepage? Just saying "text mode" isn't enough!
I dunno really. I just used streamreader in whatever default it is. That could have been part of the issue possibly.

Now I am looking and can't find what encoding it uses by default.... ?

edmund745
Jun 5, 2010
I am (still) writing a VB.net program, and want *some* way to add *some kind* of help files that have pictures. And there is no way? It seems.

At first I wanted a button (that I make myself) to "open" a help window using a helpProvider, that shows some HTML files. I don't need all the context-related stuff, the help files is just a few HTML files with links between. That's it.
...........
There is claims that this is possible, but there are no working examples. And nothing I tried will work.

I don't know anything about making CHM files, and don't need something indexed really. If there is a free program that can do that I might get desperate and try it, but I won't pay for anything. I'm using VB Express 2010 I think. But even so, the pages I have seen that use a real help button (in the upper-right, next to the close button) say that you can't have a minimize or maximize box if you have the help button..... ??? Which is hard to believe, but I don't want it, if its true.

So then I got the bright idea of just making another form, putting a webBrowser on it, and opening that and pointing it to the index page of the HTML files I would have,,,,,,,, and it gives some big long DLL error that I have no clue where to begin to fix. It begins with the words "the assembly with the display name 'microsoft.mshtml' failed to load", and if you clear that, THE HELP PAGE DOES LOAD!!! But it stops everything with this big error notice. Which is no good.

Why is this so hard? Jesus loving Christ.

At first I thought it was just me, but I have read at least 50 other people online asking the exact same thing (how to add help/show a HTM page). I tried about a dozen different methods given and none of them worked: they either produced an error so the program wouldn't run at all, or they do *nothing*. Like,,,,,,,, there is no helpProvider.open() call to make.

edmund745
Jun 5, 2010

edmund745 posted:

I am (still) writing a VB.net program, and want *some* way to add *some kind* of help files that have pictures. And there is no way? It seems. ...
I did figure part of this out: apparently you CANNOT use the web browser component unless you are using the full/pro versions of Visual Studio. ?:>|

To use the web browser component, you have to add a reference to the Microsoft html object library,,,,,, but for some reason, only the pro versions will add the reference correctly. All the express versions fail, by either not really referencing it, or just hanging (in this case VB.net Express):
Exhibit A:
http://forums.codeguru.com/showthread.php?522047-How-to-add-reference-to-Microsoft-HTML-Object-Library
Exhibit B:
http://www.pcreview.co.uk/forums/cant-add-reference-mshtml-t3489902.html


So,,, if you want to add help that is reachable from a program that you write on any of the Microsoft * Express IDEs, you MUST use a chm file. It is not possible to use the web browser component at all because it causes a DLL error message any time it is used.

edmund745
Jun 5, 2010
Update: after making a one-page chm file using MS's own HTML Help Workshop, I can confirm that not only can you not use the web browser component in VB Express,,,, you also can't provide regular help files either--since the helpProvider [apparently?] uses the web browser component to show them, and you can't add a working reference to get the web browser component that will get it to work.

So here again is another example of something I have run into, that simply does not work. Even the examples on MSDN don't work.

I tend to wonder if they crippled this on purpose? The Express versions are supposed to be for "students and hobbyists". They left dozens of data-handling back-end stuff in there that such users likely wouldn't ever need, yet the seem to have made sure that the help feature would be unusable.

edmund745
Jun 5, 2010
I am using a datetimepicker in a vb.net program (in vb.net express 2010), and it appears that the valueChanged event is firing when the form loads, leading to other errors. I found it because I had another sub call in the valueChanged event that was getting called prematurely, but only having msgbox or Messagebox.show in it indicates it is triggering as well.

I have used a couple other calendar controls elsewhere and had no similar problem with them. WTF is this? It seems like it is working wrong. I could just use a separate button to call the sub, but it seems kinda dumb.

Google finds no other people having the same problem. :|

I use a couple calendar controls elsewhere in the same program, and have no issues with them. I only used the dateTimePicker here because of lack of screen space.

,,,,,,,,,
[edit]
I can just go to using the closeUp event. Something seems f*cked though.

None of the documentation I have found says valueChanged should be firing like that.

edmund745 fucked around with this message at 00:47 on Jun 7, 2013

edmund745
Jun 5, 2010

Cryolite posted:

How many times does it fire? Once?

Are you setting its value in code anywhere, like in the form's constructor or the OnLoad event?

Where do you hook up the event, in the designer? Look at the code after the event is hooked up and see if the designer sets its value after that point to set a default value or something.

It fires once when the form loads.
I ain't done sh*t to it, other than set the maxdate and mindate, and a value in-between, in the properties (in the IDE). Nothing set during runtime by me, in form load or anywhere else.

I can find the references to it in the designer but am not really familiar with that aspect of using the IDE. I don't see anything unusual though.
It sets all the properties, then further on down has "Friend WithEvents ViewOnly_DateTimePicker As System.Windows.Forms.DateTimePicker" and then no more references in the designer.

edmund745
Jun 5, 2010

JawnV6 posted:

Uh... sounds like that's it? Set a breakpoint on the Form.designer.cs when it's setting that value, pretty sure the event fires after that.
What I find is in the form.designer.vb form.... where is the form.designer.cs form at? :|
,,,,
As far as what's on the designer.vb form----apparently there's no way to stop that.
The value has to have a valid date in it, in the IDE Form[design] tab. You can't leave the value empty, I tried. If you do, the IDE halts immediately and says that you must have a valid date there that is between the mindate and maxdate values.

My google attemps seem to indicate that the datetimepicker always has to have a valid date to set to, at least in vb.

Adbot
ADBOT LOVES YOU

edmund745
Jun 5, 2010
Does anyone know how to manually copy projects in vb.net?

I have a project I was working on, and I wanted to preserve the 'existing' condition... So I copied it to a new folder with a different name, and did a bunch more coding on it.
Problem is, it don't work anymore. There seem to be references to the first project, and all I get is a huge number of system error messages when I try to run it now.

There doesn't seem to be anyway to import stuff that works, in VB.net express 2010. Or any way to simply "copy a project" to a different location, and get all the stuff correct.... It might work in the paid version of Visual Studio, but I don't have that.

This guy says "you edit the text files with no extensions", but WTF is he talking about? ALL the files I see have extensions.
http://social.msdn.microsoft.com/Forums/en-US/vbide/thread/afd73b03-3986-4c94-ac3b-aa8b6c462a68/

I found the FileListAbsolute.txt file and tried editing that, but the first project has a whole bunch more lines in it than the second (non-functioning) project did. Just changing the file paths of the first one and copying them into the second one didn't work. I don't know if this file is an actual build-guide or if it is just a report generated after the fact however.

  • Locked thread