Generate auto increment number in a textbox using C# [closed] - c#-4.0

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to add sequence numbers in textbox but the format is 001 to onward, the main problem is when the number comes to 009, after it became 0010, four digit character. I want to reduce a zero from it, the number should look like 010. Please help me for this problem

This should meet your needs.
for (int i = 0; i <= 100; ++i)
{
Console.WriteLine(string.Format("{0:000}", i));
}

Quick and dirty. Probably not the best way to do this:
textBox1.Text = (Convert.ToInt16(textBox1.Text) + 1).ToString();
if (textBox1.Text.Length == 1)
{
textBox1.Text = "00" + textBox1.Text;
}
else if (textBox1.Text.Length == 2)
{
textBox1.Text = "0" + textBox1.Text;
}

Related

How to format number in node js? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 months ago.
Improve this question
I want that if i am given a value like 1k then it should be converted to 1000 or 1m to 100000 and so on..
1k - 10000
100k - 100000
1m - 1000000
1b - 1000000000
I have searched a lot on the internet, but I can't find any npm package that can do it as well.
i just want a code solution or a npm package to help me in it.
Maybe you can try this
var thousand = '1k'
var hundredThousand = '100k'
var hundredThousandComa = '13.5k'
var million = '1m'
var billion = '1b'
var arrayFormat = [thousand, hundredThousand, hundredThousandComa, million, billion]
arrayFormat.map((value) => {
var number = value.slice(0, -1)
var last = value.slice(-1)
if (last == 'k') {
console.log(number * 1000)
} else if (last == 'm') {
console.log(number * 1000000)
} else if (last == 'b') {
console.log(number * 1000000000)
}
})
Create a map of units to coefficients.
Parse each input string into its value and unit.
Multiply the value by the corresponding unit's coefficient to get the product.
Example:
const map = {
k: 1e3,
m: 1e6,
b: 1e9,
// etc.
};
const inputs = [
'1k',
'100k',
'1m',
'1b',
];
for (const input of inputs) {
const value = input.slice(0, -1);
const unit = input.slice(-1);
const product = value * map[unit];
console.log(value, unit, product);
}

Create string from map[string]interface{} [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
This post was edited and submitted for review 5 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
data := map[string]interface{}{
"username": 'username1',
"password": 'password1'
}
I have a map[string]interface{} data, I want to form a string like below
str = "username='username1', password='password1'"
How can I form string like above i.e. key1='value1', key2='value2'....
I am new to golang
I tried append() but was facing issues like cannot append []string to variable type string
Have you tried anything? There's lots of ways to do what you're trying to do. Some more peprformant than others, some easier to write... This would be a quick way to implement what you need:
func PrintStr(m map[string]interface{}) {
parts := make([]string, 0, len(m))
for k, v := range m {
parts = append(parts, fmt.Sprintf("%s=%v", k, v))
}
fmt.Printf("%s\n", strings.Join(parts, ";"))
}
Range over data. Add comma if not first. Write key. Write =. Write value.
data := map[string]interface{}{
"username": "username1",
"password": "password1",
}
var sb strings.Builder
for k, v := range data {
if sb.Len() > 0 {
sb.WriteString(", ")
}
sb.WriteString(k)
sb.WriteString(`="`)
sb.WriteString(fmt.Sprint(v))
sb.WriteString(`"`)
}
s := sb.String()
fmt.Println(s)

sort in Ascending Order [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Input->windows 7 was released on 1 Jan 2017
Output
1
7
2017
Jan
on
released
was
windows
Did little example to understand object parsing into int type parameter.
List<object> _obj = new List<object>() { "10", "20", "30", "d", "a", "t" };
int sum = 0;
for (int i = 0; i < _obj.Count; i++)
{
int temp;
//parsing object into int type, when we cant parse object will be 0
int.TryParse(_obj[i].ToString(), out temp);
//sum values
sum = sum + temp;
}

How to randomize the case of letters in a string in Swift? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Given a string, I would like to change the case of each letter to a random between upper and lower case.
For example:
let myString = "Have a nice day!"
let newString = "haVe A NiCe dAY!"
Swift 2
I would use arc4random_uniform and map.
let myString = "Have a nice day!"
let result = myString.characters.map { (char) -> String in
if arc4random_uniform(2) == 0 {
return String(char).lowercaseString
}
return String(char).uppercaseString
}.joinWithSeparator("")
print(result)
hAvE A NICe DAy!
Swift 3:
let result = myString.characters.map {
if arc4random_uniform(2) == 0 {
return String($0).lowercased()
}
return String($0).uppercased()
}.joined(separator: "")
Swift 4.2
let result = myString.map {
if Int.random(in: 0...1) == 0 {
return String($0).lowercased()
}
return String($0).uppercased()
}.joined(separator: "")

Web Audio filter node popping [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am getting popping when modulating a filter nodes frequency with an LFO when the filter frequency bottoms out.
I suspect this is due to the amplitude not being at the time of cutoff. Is it necessary to modulate the gain as well? I was hoping not to have to and I'm not really sure how I would anyway.
Edit: forgot link to example code http://jsfiddle.net/hyf5N/
var context = new webkitAudioContext();
var lfo = context.createOscillator();
lfo.frequency.value = 10;
var saw = context.createOscillator();
saw.type = 'sawtooth';
var filter = context.createBiquadFilter();
filter.type = 'lowpass';
var gain = context.createGainNode();
gain.gain.value = 500;
saw.connect(filter);
lfo.connect(gain);
gain.connect(filter.frequency);
filter.connect(context.destination);
lfo.start(0);
saw.start(0)
I think you're getting pops (would have to analyze waveform to see exactly why) because your LFO is modulating the frequency from -490 to 510. (freq.value = 10, + LFO ([-1,1]) * 500.) I expect the negative frequency is causing an issue.
If you want it to modulate from 0 to 1kHz, you set the frequency.value to 500, and the gain.value to 500. (The key here is that an oscillator is going to go from -1 to 1, not 0 to 1.)
Code for a rectifier:
var waveshaper = audioContext.createWaveShaper();
var curve = new Float32Array(65536);
for (var i=0; i<32768; i++)
curve[i] = 0.0;
for (var i=32768; i<65536; i++)
curve[i] = (i/32768) - 1;
waveshaper.curve = curve;
I couldn't figure out how to make the waveshaper work for me since I didn't want to bottom out the lfo signal at 0 but rather make it so the modulation wouldn't push the filter frequency below 0. I ended up using a scriptProcessorNode like so
modulationProcessor = this.context.createScriptProcessor(4096);
modulationProcessor.onaudioprocess = function(e) {
// bottom out frequency modulation at filter.frequency == 0 to avoid popping
var input = e.inputBuffer.getChannelData(0);
var output = e.outputBuffer.getChannelData(0);
var frequency = filter.frequency.value;
for (var i = 0; i < input.length; i++) {
output[i] = (input[i] + frequency) > 0 ? input[i] : input[i] - (input[i] + frequency);
}
}
It isn't perfect since it seems like if you are adjusting the filter frequency a lot you can still get popping sometimes. I think it is because the filter value can get stale while the buffers are being written. It seems to work fine if you aren't live editing the filter frequency though.

Resources